Hello,
This is a really simple question but I just don't see the error here:
def foo():
x = input('write something: ')
if x == 1 or x == 2:
print('OK')
else:
print('NO')
print(x)
Why does it keep printing NO?
Also, I have a more complicated one:
def foo(x, y):
if x == 'a' or x == 'b' and y == 'z':
print('OK')
elif x == 'a' or x == 'b' and y == 'w':
print('OK2')
It keeps printing OK instead of OK2.
I have read the documentation and the use I'm giving to the and and or expressions seems correct and logical to me, but obviously it's not (or my logic is flawed).
Any ideas?