LearnFrenzy
Sign in Take a free test

Tuples · Find the Error · Question 4

Error: not enough values to unpack Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 4 Back to Exercise

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

main.py
line = "Ravi,78"
name, marks, grade = line.split(",")
print(name, marks, grade)
  • A It prints Ravi 78 None
  • B ValueError: split gives 2 values but 3 names are waiting Correct
  • C TypeError: split returns a list
  • D IndexError: list index out of range
Correct Answer: Option B

Missing values are not filled with None. Check len() first, or use a starred name.

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