Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

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

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)

Answer: c
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.

Join The Discussion