Q. Is the following Python code valid? >>> a,b=1,2,3

  • (A) yes, this is an example of tuple unpacking. a=1 and b=2
  • (B) yes, this is an example of tuple unpacking. a=(1,2) and b=3
  • (C) no, too many values to unpack
  • (D) yes, this is an example of tuple unpacking. a=1 and b=(2,3)
πŸ’¬ Discuss
βœ… Correct Answer: (C) no, too many values to unpack
Explanation: for unpacking to happen, the number of values of the right hand side must be equal to the number of variables on the left hand side.

Explanation by: Mr. Dubey
for unpacking to happen, the number of values of the right hand side must be equal to the number of variables on the left hand side.

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
722
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
96%
Success Rate