Declaring more than one variable in single line:
=>> yes we can declaring more than one variable in a single line and assign it different value.
x,y=1,2 print(x) print(y)
==>> we can assign any variable with and data type of values in single line
a,b,c=1,'mohit','123as' print(a,type(a)) print(b,type(b)) print(c,type(c))
1 <class int> mohit <class str> 123as <class str>
=>> We can also assign a single value to more than one variable in single line.
x=y=z=12 print(x) print(y) print(z) print(x,y,z) print(x+y+z)
12 12 12 12 12 12 36
Thank you and if you have any problem regarding this please let me know in the comment box
Top comments (0)