Consider a
to be an array
print(a.append(1))
Why doesn't this print a
's elements, it gives a message as None
, whereas
print(a.index())
gives the desired result?
Consider a
to be an array
print(a.append(1))
Why doesn't this print a
's elements, it gives a message as None
, whereas
print(a.index())
gives the desired result?
Why doesn't this print a's elements
Why should it? append is meant to modify the list in-place. When you print(a.append(1))
, you are appending 1 to a, and printing the result of calling append (the object returned by the append method), which is None.