top of page

Assigning multiple variables at once in Python

Updated: Apr 19, 2023




We can assign values to multiple variables by passing comma separated values as shown below:



a, b, c = 10, 20, "Hello World!"
print(a)
print(b)
print(c)

#printing multiple values
print(a,b,c)



If the same value needs to assigned to several variables, we can do it the following way:


a = b = c = 100
print(a)
print(b)
print(c)

If the values present in a list needs to be assigned one by one to different variables, we can do so in the following way.


#unpack a collection
just_values = [10, 20, "Hello World!"]
a, b, c = just_values

print(a)
print(b)
print(c)

The link to the Github repository is here .

🔥 LLM Ready Text Generator 🔥: Try Now

Subscribe to get all the updates

© 2025 Metric Coders. All Rights Reserved

bottom of page