Python Assign Values to Multiple Variables


Assign Value 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)
Try it Yourself »

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

Example

x = y = z = "Orange"
print(x)
print(y)
print(z)
Try it Yourself »


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.