LearnFrenzy
Sign in Take a free test

Tuples · Find the Error · Question 3

Error: too many values to unpack Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
record = ("Asha", 21, "CSE")
name, age = record
print(name, age)
  • A ValueError: the tuple has 3 items but only 2 names; add a name or use name, age, *rest = record Correct
  • B It prints Asha 21
  • C TypeError: record is a tuple
  • D IndexError
Correct Answer: Option A

Unpacking is strict about the count unless a starred name absorbs the extras.

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