0
This program is giving me wrong output.
User_gender = input ('type your gender').title() If user_gender != 'M' or 'F' or 'O' : Print ('wrong input') Print ('hello') When I type M or F or O the output is always same That is 'wrong input' But I want the program to print 'hello' when we type M or F or O
2 Respostas
+ 5
In your if block
First it will process user_gender != "M" it may result true or false
Then The process will be
True/False or "F"
Which will always be True as string are considered as True
So let there be any input if block will always run showing wrong input.
Try this
valid input =["M","F","O"]
if user_gender in valid input:
print("Hello")
else:
print("Wrong Input")
May This Helps You 😊