dimanche 3 novembre 2019

How to add an "else" option after a list of "if" commands in python

There is a bank app and you have to log in, and certain codes have certain users. how would i make it to where if none of the codes were used, i can have a message saying no valid code was entered?

#login id 10
account_name1 = "Mark"
account_balance1 = "150"

#login id 11
account_name2 = "John"
account_balance2 = "190"

#login id 12
account_name3 = "Bob"
account_balance3 = "210"

login_id = input("What is your login id?")

if login_id == "10":
    print("Hello, %s, your balance is $%s." % (account_name1, account_balance1))


if login_id == "11":
    print("Hello, %s, your balance is $%s." % (account_name2, account_balance2))


if login_id == "12":
    print("Hello, %s, your balance is $%s." % (account_name3, account_balance3))

#then here i would have code making it to where if something except 10,11,12 was entered, it would give a message

Aucun commentaire:

Enregistrer un commentaire