Why print(b) is a? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
28th Jan 2020, 12:15 AM
Urbo Fresco
Urbo Fresco - avatar
2 Answers
+ 6
'and' checks that chain of expressions for True/False, until it either finds a False one, or the chain is over. a > 5 and 'a' Since a is indeed > 5, the next expression - is 'a' True or not? - is evaluated. Since 'a' is True, the following part after 'or' isn't executed anymore. 'a' therefore is the final result and therefore becomes the new value of the variable.
28th Jan 2020, 12:21 AM
HonFu
HonFu - avatar
+ 2
I got it! Thanks a lot!!!
28th Jan 2020, 12:23 AM
Urbo Fresco
Urbo Fresco - avatar