Python Tutorials · Python Variables

Assign Multiple Values

Learn all about Assign Multiple Values in this comprehensive tutorial.

5 min read beginner
  • Python allows you to assign values to multiple variables in one line:
  • And you can assign the same value to multiple variables in one line:
  • If you have a collection of values in a list, tuple etc.

Many Values to Multiple Variables

Python allows you to assign values to multiple variables in one line:

python
Note: Note: Make sure the number of variables matches the number of values, or else you will get an error.

One Value to Multiple Variables

And you can assign the same value to multiple variables in one line:

python

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.

python

Learn more about unpacking in our Unpack Tuples Chapter.

Module quiz

2 questions
1

Which of the following is true about Assign Multiple Values?

2

What is the most common pitfall when working with Assign Multiple Values?

Answer all questions to submit.