+ 1
please explain this Python code
why does it execute the first if statement, if x is not true? https://code.sololearn.com/cvfSqJLMaqYI/?ref=app
4 Answers
+ 3
x is not an empty list. It contains an empty tuple. So x is True.
+ 3
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.Â
In this case 1 equals False and 2 equals True
+ 1
Thanks for the answers. Finally I've got it. I should ask if bool(x) == True and not if x == True.