Is there a way in Python to do like this:
a, b, = 1, 3, 4, 5
and then:
>>> a
1
>>> b
3
The above code doesn’t work as it will throw
ValueError: too many values to unpack
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just to add to Nolen’s answer, in Python 3, you can also unpack the rest, like this:
Unfortunately, this does not work in Python 2 though.