0
Please need help in 'or' and '!=' operator.
#THE CODE x=input("Here:") if x != 'hello' or 'Hello': print("Yes") else: print("No") #Ends here. I was making a dice.So here I wanted to ask roll dice 'yes' or 'no'.(No exactly the literal code here not exact code).But the thing here is No matter if I type "hello" or "Hello" it always give the output "true".Even after using the != operator.I know it is cause of that 'or operator'.But if I put it as not equal it should not print yes even when I give input literally something else .It still gives me "Yes.Please help.Its in mind like "If x not equal to 'hello' or "Hello" print 'yes' or else print 'no' .
2 Réponses
+ 1
x = input("Here:")
if x != 'hello' or x != 'Hello':
print("Yes")
else:
print("No")
+ 1
Here is a quick tip, you can use lower function to avoid inputs such as Hello , hEllo and etc:
x = input("Here:").lower()
If x == "hello":
print("No")
else:
print("Yes")