+ 1
Why does it break loop...when input is mirror
while True: print("mirror or lense") x = input(": ") if x != "mirror" or "lense": print("wrong input") break print("input was right")
3 Respuestas
+ 3
You should use and... Otherwise, when you enter mirror, it checks mirror != mirror, this returns false but mirror != lense returns true and false or true returns true... So x != "mirror" or x != lense returns true
https://code.sololearn.com/cY6l7yL8W9Z7/?ref=app
I advise you test it entering mirror, lense and another word on separate lines
+ 1
while True:
print("mirror or lense")
x = input()
if x not in ('mirror','lense'):
print("wrong input")
break
print("input was right")
+ 1
thanks...bhaiya