Reputation: 3
Rather new to programming, wanted to play around with input and I hit a stump
print("Alrighty. Are you male or female?")
gender_choice1 = print("A) Other")
gender_choice2 = print("B) Male")
gender_choice3 = print("C) Female")
gender_answer1 = "of course"
gender_answer2 = "Of course sir"
gender_answer3 = "Of course madame"
if input() == "a":
print(gender_answer1)
if input() == "b":
print(gender_answer2)
if input() == "c":
print(gender_answer3)
every time I try to answer anything other than "a" it refuses to print anything and just puts out a blank space.
Upvotes: 0
Views: 38
Reputation: 11414
Every time you call input()
, Python will try to read new input. So each of your input()
calls in your if
-conditions will have different inputs. If you want each of them to compare the same input, assign input()
to a variable first.
i = input()
if i == "a":
print(gender_answer1)
if i == "b":
print(gender_answer2)
if i == "c":
print(gender_answer3)
Upvotes: 1