Python Variables - Assign Multiple Values
Python Variables - Assign Multiple Values
Dark mode
Dark code
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP BOOTSTRAP HOW TO W3.CSS C C++ C# REACT R JQUERY DJANGO
Python HOME
Python Intro
Python Get Started
Python Tuples
Python Sets Try it Yourself »
Python Dictionaries
Python If...Else
Note: Make sure the number of variables matches the number of values, or else you will get an error.
Example
x = y = z = "Orange"
COLOR PICKER
print(x)
print(y)
print(z)
Try it Yourself »
Unpack a Collection
If you have a collection of values in a list, tuple etc. Python allows you to extract the values into variables. This is called
unpacking.
Example
Unpack a list:
Try it Yourself »
ADVERTISEMENT
ADVERTISEMENT
FORUM | ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.