0
aTup = (1,2,3)    
print(list(aTup).append(4))

Why does I None?

Cory Kramer
  • 107,498
  • 14
  • 145
  • 201
quest
  • 2,983
  • 1
  • 13
  • 22

2 Answers2

4

append returns None, simple as that. It does however modify the list

>>> l = [1,2,3]
>>> print(l.append(4))
None
>>> l
[1, 2, 3, 4]

The reason is that it isn't meant to be called with the return value used mistakenly for an assignment.

l = l.append(4) # this is wrong
Cory Kramer
  • 107,498
  • 14
  • 145
  • 201
0

It's because the method append() does not return any value.

If you want to print the list after the update, you can do the following:

aTup = (1,2,3)    
aList = list(aTup)
aList.append(4)
print(aList)
RoaaGharra
  • 690
  • 5
  • 18