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.
for example
x,y=1,2
print(x)
print(y)
output is
1
2
==>> we can assign any variable with and data type of values in single line
For example
a,b,c=1,'mohit','123as'
print(a,type(a))
print(b,type(b))
print(c,type(c))
output is
1 <class int>
mohit <class str>
123as <class str>
=>> We can also assign a single value to more than one variable in single line.
For example
x=y=z=12
print(x)
print(y)
print(z)
print(x,y,z)
print(x+y+z)
Output is
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)