Reputation: 35
I am trying to get my Senior Discount code to work properly. It asked the user for their age and what state they live in. If they are 70 and live in Florida, than they qualify. If both needs aren't met, they do not qualify:
def main():
age = eval(input("How old are you?: "))
state = input("What state do you live in?: "))
if age >= 70:
print("You qualify for a discount!")
if state == "Florida":
print("You qualify for a discount!")
else:
print("You do not qualify for a discount!")
else:
print("You do not qualify for a discount!")
main()
If the user inputs correct age and state, the program outputs the correct code. If the user inputs correct age, but incorrect state, the program outputs both "You do not qualify" and "you qualify" statements. I am stuck on how to create the correct if, else coding statements.
Upvotes: 1
Views: 930
Reputation: 1854
def main():
age = eval(input("How old are you?: "))
state = input("What state do you live in?: ")
output="You qualify for a discount!" if age >= 70 and state.lower() == "florida".lower() else "You do not qualify for a discount!"
print(output)
Upvotes: 0
Reputation: 12927
if age >= 70 and state == "Florida":
print("You qualify for a discount!")
else:
print("You do not qualify for a discount!")
Upvotes: 2