-3

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;

kaneroy
  • 3
  • 3

1 Answers1

0

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)
Ajax1234
  • 69,937
  • 8
  • 61
  • 102