I'm wondering why the variable lengthOfList
can store len(l)
but the variable reverseOfList
cannot store a method being called on a list.
If I call l.reverse()
and print(l)
I can see the reverse but why can't the reversed list be stored in a variable?
Please see example code below.
l = [1,2,3]
lengthOfList = len(l) #3
reverseOfList = l.reverse() # Global frame None
print(reverseOfList) #None