0

Code :

input_tuple = ('Monty Python', 'British', 1969)
y = list(input_tuple)
z = y.append("Python")
tuple_2 = tuple(z)
print(tuple_2)

expected o/p:

('Monty Python', 'British', 1969, 'Python')

But getting as :

TypeError                                 Traceback (most recent call last)
<ipython-input-30-037856922f23> in <module>
      3 y = list(input_tuple)
      4 z = y.append("Python")
----> 5 tuple_2 = tuple(z)
      6 # Make sure to name the final tuple 'tuple_2'
      7 print(tuple_2)

TypeError: 'NoneType' object is not iterable
wjandrea
  • 28,235
  • 9
  • 60
  • 81

1 Answers1

2

that's not how append works. you do not need to save y.append value in z it will directly updated in y, so create tuple of modified y

look at this, this works as you wnats..

input_tuple = ('Monty Python', 'British', 1969)
y = list(input_tuple)
y.append("Python")
tuple_2 = tuple(y)
print(tuple_2)