In trying to understand how to work with classes, objects, and methods, Please explain why print(list.sort()) does not work like list.sort() followed by print(list).
list = [5, 1, 2]
print(list.sort())
#output is None
VS.
list.sort()
print(list)
#output is [1, 2, 5]
Explained above: I expected print(list.sort()) to output a sorted list instead of None
>Solution :
As you can read in the documentation of list.sort
This method modifies the sequence in place for economy of space when sorting a large sequence. To remind users that it operates by side effect, it does not return the sorted sequence (use sorted() to explicitly request a new sorted list instance).
(bold text by me)