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

Has*_*anQ 0 python if-statement

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
Run Code Online (Sandbox Code Playgroud)

fin*_*mer 6

Put the account data into a dictionary using the id as keys. If an id exist you can print out the hello message using the corresponding account data, otherwise print an error message:

accounts = {
    "10": {
        "name": "Mark",
        "balance": "150",
    },
    "11": {
        "name": "John",
        "balance": "190",
    },
    "12": {
        "name": "Bob",
        "balance": "210",    
    }
}

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

try:
    print(f"Hello, {accounts[login_id]['name']}, your balance is {accounts[login_id]['balance']}")
except KeyError:
    print("No valid code entered!")
Run Code Online (Sandbox Code Playgroud)