+ 2
Python - Why is output None?
a=[24,13,32,18] print(a.sort())
3 Antworten
+ 11
sort() is an object method.
It doesn't return value. It sort the value in place.
sorted() also is a function which sorts items and returns as new values.
i.e pop() method will return the popped item
+ 2
.sort() is a function, so it needs to be called before printing
you’d be better off doing
a=[your numbers]
a.sort()
print(a)