Skip to content

Question 10

What is the output of the following code?

tup1 = (1, 2, (3,))
print(tup1.append(9))
Hint

Try adding an element into a tuple.

Solution

You can't add any new elements into a tuple once it is defined. Trying to do so will raise an AttributeError:

AttributeError: 'tuple' object has no attribute 'append'
Answer

Executing this code yields an error