+ 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")

13th Apr 2018, 10:34 AM
ALBERT SAURAV
ALBERT SAURAV - avatar
3 Respostas
+ 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
13th Apr 2018, 10:49 AM
cyk
cyk - avatar
+ 1
while True: print("mirror or lense") x = input() if x not in ('mirror','lense'): print("wrong input") break print("input was right")
13th Apr 2018, 10:47 AM
Pavan Kumar T S
Pavan Kumar T S - avatar
+ 1
thanks...bhaiya
13th Apr 2018, 10:53 AM
ALBERT SAURAV
ALBERT SAURAV - avatar