+ 2

NECESITO AYUDA! Por favor!!!

Porque pasa esto?? No debería ser falsa la condición?? if 1 or 2 == 0: print("Hola!") else: print("Chau") Output: Hola

30th Apr 2020, 4:04 AM
Orking20
Orking20 - avatar
2 Respostas
+ 1
I don't speak much Spanish so maybe you can translate this from English. if 1 or 2 == 0 prints "Hola" because one of the two conditions are true. It's evaluated like this: if 1 or (2 == 0). Where the 1 becomes a boolean expression which is evaluated as true. You can fix this by changing the condition to: if (1 or 2) == 0: print("Hola!") else: print("Chau")
30th Apr 2020, 4:23 AM
Damyian G
Damyian G - avatar
+ 1
Thanks you!!!! I spent two hours thinking in the solution
30th Apr 2020, 4:31 AM
Orking20
Orking20 - avatar