You have some mistakes in the way you check the options.
Firstly how you check if a variable has value in a list:
(character != "male") or ("female")
This is incorrect, the first part (character != "male")
correctly checks if the value of character is not male, the second part (("female")
) though checks the truth value of just the string "female", this will always be true. Also the two conditions should be evaluated with and end
(you want to error if character is neither)
To do this check you should do
(character != "male") or (character != "female")
Also python provides a more elegant solution:
character not in ("male", "female")
The second thing is how you put the different conditions together. You are chaining with the and
operator but you want to error if any of the three values have wrong choiches so you should use or
The whole code would become:
print("Hello, this is my first mini-game. Let's test it out")
character = input("Please choose your gender (male, female): ")
age = input("Please choose your age (child, teen boomer): ")
hobby = input("Please choose your hobby(gaming, school, sport): ")
if character not in ("male", "female") or age not in ("child", "teen", "boomer") or hobby not in ("gaming", "school", "sport"):
print("Invalid options")
else:
print("Beautiful choices you are now a {0} that is a {1} and likes {2}".format(character, age, hobby))