+ 2
Why the code in description giving "None" as a output ?
a = [2,3,8,1,4] print(a.sort())
4 ответов
+ 7
because a.sort() sorts the elements in place and doesn't returns a new list or anything so printing it out returns None as nothing returned by calling that sort method
+ 6
It is because the sort() modifies the list in place and doesn't return anything.
You could say-
a.sort()
print(a)
OR
print(sorted(a))
+ 5
It's analogous to a.reverse() and reversed(a)
+ 1
Avinesh what is function of sorted() ?