+ 1

Why does this happen

Even when I write "abc" in the input it still gives output as "you" https://code.sololearn.com/c6R1m3ue7N3H/?ref=app

15th Dec 2019, 7:09 AM
Yash
Yash - avatar
1 Antwort
+ 5
This adaptation of your code will work: while True: x=input() if "lol" in x: print("You") elif "Lol" in x: print("you") elif "abc" in x: print("me") break Your line which states: if 'lol' or 'Lol' in x: has caused the error. The code is looking for 'lol' to be True. If x is not True, it substitutes 'Lol' into x, to make it True. Hence your output is always 'You' Example for you to test x = input() or 'test' print(x)
15th Dec 2019, 7:25 AM
Rik Wittkopp
Rik Wittkopp - avatar