Assign multiple variables in a single line
We can use commas and variables to assign multiple values to the variable in a single line. We can assign any data type to variables whether it's a string, number or list in a single line.
Python: 3.0    Anurag Rana    29 Jan 2022   0
Login to upvote
1
2
3
4
5
6
7
8
a, b, c = 'a', 123, [1,2,3,4,5]

print(a)
# a
print(b)
# 123
print(c)
# [1, 2, 3, 4, 5]
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com