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)
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β
Pythonβs list.append
method mutates the list in-place. Python methods that mutate their receivers will always return None.
Exactly! Like soβ¦
βββ
t1=[1,2,3]
t1.append(5)
print(t1)
βββ
See also @chuckadams explanation.