Sorted List in Python
Level 245 keystrokes
This prints a sorted copy of the list. The sorted() function returns a new sorted list without modifying the original.
Python code
# Create an unsorted list of numbers1nums = [3, 1, 4, 1, 5, 9]# sorted() returns a new sorted list in ascending order# The original list nums remains unchanged2print(sorted(nums))Output
[1, 1, 3, 4, 5, 9]
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
,× 5(× 2)× 2[× 1]× 1=× 1