← back to unit
Easy
# sorting easy
Change It in Place
Two spells: sorted(nums) conjures a sorted COPY, while nums.sort() rearranges the original forever. 🪄
You get a list of nums. Print the sorted version on line one, then print the ORIGINAL list on line two — unchanged! Choose your spell carefully.
Example:
Input: nums = [3, 1, 2]
Output:
1,2,3
3,1,2
sorted(nums) builds a brand-new sorted list ([1, 2, 3]) without touching nums at all, so the original still prints as 3,1,2 on the second line.
💡 need a hint?
sort-in-place.py🔒 given lines are locked — write your code in between
loading...