Why does [1].append(2) evaluate to None instead of [1,2]? [duplicate]
Why does print [1].append(2)
evaluate to None? I expect [1,2]
>>> print [1].append(2)
None
Solution 1:
That's because append returns nothing (= None
).
>>> print [1].append(2)
None
Solution 2:
array.append
doesn't return the array you appended to, it returns None
.