LearnFrenzy
Sign in Take a free test

Tuples · Predict the Output · Question 8

Nested unpacking Answer, explanation & discussion

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

What is the output of the following Python program?

main.py
data = ("Asha", (91, 85))
name, (m1, m2) = data
print(name, m1 + m2)
  • A Asha (91, 85)
  • B ValueError
  • C Asha 9185
  • D Asha 176 Correct
Correct Answer: Option D

The target (m1, m2) matches the inner tuple, so both marks are unpacked in one statement.

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