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

15th Jun 2020, 2:39 PM
Kairav Bhatia
Kairav Bhatia - avatar
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 😊
15th Jun 2020, 2:50 PM
Hacker Badshah
Hacker Badshah - avatar
15th Jun 2020, 2:46 PM
Kiran Deep Naidu
Kiran Deep Naidu - avatar