Similar to strings, lists also have many utility methods. Yet, if string methods don’t modify the initial string and return a new one, list methods make changes to the initial list itself.
Count the number of occurrences of
Make the list empty
Copy and return the list
Find the first occurrence of
Reverse the list
Sort the list in increasing order
Again, most of the names are very intuitive. Yet, it’s not mandatory to remember them all. A quick googling will give you the needed results. These examples are for demonstration purposes. To show what is possible with Python lists.
nnumbers, you are asked to sort them in ascending order and print them in the output.
The first line of the input contains a single number
n. The next
nlines contain integers each on a separate line.
The program should output all the numbers on a single line in increasing order separated by a space.
5 1 4 3 0 -1
-1 0 1 3 4
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB