LearnFrenzy
Sign in Take a free test

Tuples · Predict the Output · Question 3

Changing a list stored in a tuple Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

What is the output of the following Python program?

main.py
t = (1, [2, 3])
t[1].append(4)
print(t, len(t))
  • A TypeError
  • B (1, [2, 3], 4) 3
  • C (1, [2, 3]) 2
  • D (1, [2, 3, 4]) 2 Correct
Correct Answer: Option D

The tuple still holds the same two objects; one of them, a list, grew.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links