0
python if
a = int(input()) b = int(input()) if a or b == 1: print ("11") else: print ("else") input: 2 2 output: 11 Why???????
1 Answer
+ 3
You want to write a or b have to be 1, right?
a==1 or b==1
Your condition instead means:
if a exists (!=0) or b==1
'if x' only checks if x - whatever it is - is not False. So any number != 0, any container with at least one item, any string with at least one sign in it (even space) will be True.