why does this code print None and
a = [1,2,3,4]
print(a.reverse())
while this will print a reversed list
a = [1,2,3,4]
a.reverse()
print(a)
Because the function reverse doesn't return anything, ence why you get a None
When you print(a.reverse())
, you print the result of the function .reverse() on a, but reverse essentially modify "a" without returning anything