Join the discussion
Ask questions, share your code and help other Python learners. It's free.
Log in to comment, vote and follow discussions.
Continue with Google
or
Already have an account?
New to Space Python?
Check your inbox
We sent an activation link to . Open it in this browser and you'll come straight back here, logged in.
Nothing after a few minutes? Check your spam folder.
Comments 5
Join the discussion CommentAlready have an account? Log in
-
numbers.sort()sorts the list in place and returns None.-
sorted(numbers)returns a new sorted list and leaves the original alone.So
x = numbers.sort()sets x to None. Use one of:That's literally the bug I had. Thanks!
There's a challenge called "sort() returns None" for a reason š
Both accept
key=andreverse=True. E.g.sorted(names, key=len)sorts by length.And
key=str.lowerfor case-insensitive sorting. Without it "Zebra" comes before "apple".