Code Lab BetaBUILD. RUN. DISCOVER.
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
PYTHON STRUCTURES / CHAPTER 06 / Learn / LESSON 09
sorted(x) returns a NEW sorted list; x stays unchanged.
nums = [3, 1, 2]
ordered = sorted(nums)
print(nums) # [3, 1, 2]
print(ordered) # [1, 2, 3]x.sort() sorts in place and returns None — do not write y = x.sort().
Learn: sorted leaves original alone.
DATA LAUNCH STANDBY
›