Not sure why the append function returns 'None" in following code
dw=[1,3,5]
dw=[0]+dw
print(dw,type(dw))
dw=dw.append(12)
print(dw)
Output is: ([0, 1, 3, 5],'list'), None.
Why not [0,1,3,5,12] with append function?
Thanks;
Not sure why the append function returns 'None" in following code
dw=[1,3,5]
dw=[0]+dw
print(dw,type(dw))
dw=dw.append(12)
print(dw)
Output is: ([0, 1, 3, 5],'list'), None.
Why not [0,1,3,5,12] with append function?
Thanks;
You are assigning a value to a list accessing the append
method. The append
method does not return anything.
dw=[1,3,5]
dw=[0]+dw
print(dw,type(dw))
dw.append(12) #here, just call append and not assign it to a variable
print(dw)