0
zen (or anyone else who knows what to do) please help again
name_gender_type = ['Female','female','Male','male'] if input('Female') or input('Male') in name_gender_type: print ("hi") else: print ("ooh try again") i tried to expand on it to make it detect specific answers, so i can make it detect male or female and print different responses. is this the way to do it or do i need to make a seperate list and input system? it keeps printing the word "Femalehi"
3 Answers
+ 3
What you put in input() is printed, it's meant to tell the user what is expected as input.
Here is what you apparently wanted to do:
t = input()
if t in ['Female', 'Male']:
print ("hi")
else:
print ("ooh try again")
Here is another example which gives a different answer whether the type is male or female, like suggested Kamal:
t = input().lower()
if t == 'female':
print ("hi")
elif t == 'male':
print ("hello")
else:
print ("ooh try again")
0
Your question is confusing. If you want to take input from the user then you must use:
gender = input("Enter your gender, Male or Female?)
if gender == "male" or gender == "Male":
print("Your message goes here.")
elif gender == " female " or gender == "Female":
print(" Your desired message for female goes here")
else:
print("Opps! Please enter again your gender: Male/Female")
Try this in your IDE. I typed this from mobile app, check indentation if this doesn't run.
Cheers!
0
thanks both of you, but zens has less typing lol.