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

Why does it display None?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
quest
  • 3,576
  • 2
  • 16
  • 26

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
  • 114,268
  • 16
  • 167
  • 218
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
  • 710
  • 5
  • 19