+ 2
Can someone explain this problem
a = 5 b = 7 c= b = a print(a) print(b) print(c) Here, every variable's value is coming 5. Why is it like that. It could be 7, why only 5
6 Answers
+ 3
Variable gets the value assigned on the right.
In this case, however, it starts from the far right.
+ 3
When u wrote :
c = b = a
It works like this
c = (b = a)
a = 5 so b = 5
Then c = 5
That's why every variable outputs 5
+ 2
C=b=7
B=a=5
C=a=5
Here a=5
B=5
C=5
kartik dhingra
+ 1
A assign in b&c
+ 1
U write:
C=b=a
It read as
C=(b=a)
As per the priority order of different operators , parentheses (),have highest priority
So,
A=B=C=5