1

I am trying to create a list and sort it. If I am splitting the steps in separate statements, it works like I expect:

mylist = [4, 1, 2, 6, 0, 9]
mylist.sort()

gives me the expected result:

[0, 1, 2, 4, 6, 9]

while

mylist = [4, 1, 2, 6, 0, 9].sort()

results in

None

I don't understand why. I would expect, that in the second example, the list would be sorted and assigned to mylist

Cryn
  • 1,005
  • 1
  • 9
  • 13

0 Answers0