+ 1
Why "print(Letter.reverse())" gives output as None!?
I tried "Letters.reverse()" which put the objects in the list in reverse index. And if I try "print(letters)" then it shows correct output. But I tried "print(letters.reverse())", what is the reason that it gives the output as "None"!?
4 ответов
+ 1
Thank you ~ swim ~ !!!
+ 1
There are such called inplace methods, that are often used on mutable objects, such as lists and dictionaries.
Inplace methods modify the object self, but aren't often supposed to return anything. list.append is an inplace method.
Immutable objects don't have such inplace methods.