+ 1
Explain this code
a=0 or 1 b=0 or 2 c=a or b print (a+b+c) Output--------------------- 4
2 Answers
+ 3
The "or" operator basically returns a truthy value among the two given values(Truthy value can be anything except 0, None, etc)
So the variable a is assigned 1(truthy value)
Variable b is 2(truthy)
And c is assigned 1(both values are truthy but 1 is specified before 2)
And a+b+c will equal 1+2+1 which is 4
And so it prints 4
0
Why not take the value of a = 0