Why does:
x = (5,4,3)
y = list(x)
y.sort()
work, but
x = (5,4,3)
y = list(x).sort()
not work?
>Solution :
y = list(x)
this calls the function list on x and puts the result in y
y = list(x).sort()
this calls the function list on x, call .sort() on the resulting list, then store the return of .sort() in y, the return of .sort() is None.
the list is sorted in memory but the sorted list is thrown away, and only None is stored in y.
relevent What is the difference between sort and sorted