Back to Python Notes
Topic #11

Assign Multiple Values

Python lets you assign several variables in one line and unpack collections directly into names. It is a small trick that removes a lot of boilerplate.


Many Values to Multiple Variables

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

Example

  x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)

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:

Example

  x = y = z = "Orange"
print(x)
print(y)
print(z)

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

fruits = ["apple", "banana", "cherry"]
x, y, z = fruits
print(x)
print(y)
print(z)

Learn more about unpacking in our Unpack Tuples Chapter.

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Assign Multiple Values – FAQs

Quick answers about learning Assign Multiple Values in Python.

This free note from Coding Now Tech Institute explains Assign Multiple Values in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Assign Multiple Values, is 100% free with no signup required.
With focused practice, most students grasp Assign Multiple Values in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now