Append in list beginner

Hello,everyone!I know it is a simple question ,but I am a kettle)Why does Pycharm print"None" when I run such a code?

t1=[1,2,3]
t2=t1.append(5)
print(t2)

Hi, you must print β€œt1” not β€œt2”

2 Likes

Python’s list.append method mutates the list in-place. Python methods that mutate their receivers will always return None.

1 Like

Exactly! Like so…

β€˜β€™β€™
t1=[1,2,3]
t1.append(5)
print(t1)
β€˜β€™β€™

See also @chuckadams explanation.