Please need help in 'or' and '!=' operator. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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' .

5th Feb 2022, 4:22 PM
Dr Doctor
Dr Doctor - avatar
2 Answers
+ 1
x = input("Here:") if x != 'hello' or x != 'Hello': print("Yes") else: print("No")
5th Feb 2022, 4:32 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 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")
5th Feb 2022, 4:41 PM
Devnull
Devnull - avatar