84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
业精于勤,荒于嬉;行成于思,毁于随。
Because the type returned by the sort method of List is , your print here is not list1.
>>> list1=[3,2,5,6,1] >>> print type(list1.sort())
Because sort has no return value
I just encountered this problem recently. The reason is that list1.sort() only sorts the elements in list1, and then returns NoneType. If you want to get the sorted list directly, you should use the sorted function.
You can use sorted
>>> list1=[3,2,5,6,1] >>> print sorted(list1) [1, 2, 3, 5, 6]
sorted returns a new list. sort sorts in place.
Because the function oflist.sort()is to sort the elements of the list, rather than turninglist.sort()itself into a sorted list
list.sort()
Because the type returned by the sort method of List is, your print here is not list1.
Because sort has no return value
I just encountered this problem recently. The reason is that list1.sort() only sorts the elements in list1, and then returns NoneType. If you want to get the sorted list directly, you should use the sorted function.
You can use sorted
sorted returns a new list. sort sorts in place.
Because the function of
list.sort()
is to sort the elements of the list, rather than turninglist.sort()
itself into a sorted list