+ 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
2 Réponses
+ 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)