New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Why print(b) is a?
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.
+ 2
I got it! Thanks a lot!!!