🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Python Notes
Topic #11

Assign Multiple Values


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 CodingNow 2.0'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 CodingNow 2.0 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 CodingNow 2.0, 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 CodingNow 2.0'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 CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now