vendredi 27 mars 2020

Senior discount python code using if,else

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.

Aucun commentaire:

Enregistrer un commentaire