Solved

Why does sort() return None?

TomBeckerOP

Seems like it would be more useful to return the list.

2

Comments 4

Join the discussion

Already have an account? Log in

  1. SamPrice Solutionreplies: 2

    It's a deliberate signal: methods that modify an object in place return None, so you don't confuse them with functions that return a new object. If you want a new sorted list, use sorted().

    8
      1. ZosiaN

        random.shuffle returning None got me once. Same lesson.

        4