0
x,x = y,y
x=1 y4 x,x = y,y print(x+y) Can someone explain this?
3 Answers
+ 2
The output is:
name 'y4' is not defined
... because on second line you must probably write y=4 ^^
After having correted it, the output is '8' because on third line you assign the value of y to x twice ( one first time, and another with the same statement ), so x==4 and also y, and on last line you print the sum of x and y == 4+4 == 8 :P
+ 1
your code shouldn't work. however if you want to understand what a,b=b,a means check this exemple :
a=1
b=2
a,b=b,a
in this exemple 'a' will be equal to 2 and 'b' will be equal to 1.
name,family,age='Gandalf','Grey',572
is the same as :
name="Gandalf"
family="Grey"
age=572
0
So what's the output?
cause i got that code from challenge so i dont know the right answer