Hello I'm not too sure how to word this, but I'm a beginner in python so I know my code will look really rough but its what I've found from trial and error to work for me. So onto my question, I'm trying to build a mock bank interface this is what the main menu looks like:
#!/usr/bin/env python from time import sleep from CustomerCreator import CreateCustomer users = {} def main(): value = 0 while value == 0: print("Hello and Thank You for Choosing to Bank With the Best!\n\t\tYour Service is Appreciated!") sleep(0.5); print("Please choose one of the following: " "\nCreate New User: 1" "\nManage Your Account: 2" "\nTerminate Your Account: 3" "\nExit Application: 0") sleep(0.25); selection = int(input("Your Selection: ")) value += selection if value == 1: print("Welcome To The New User Menu") CreateCustomer.create_user() # make a class to reset the user back to the main menu if value == 2: input("Enter Account Number or Name to Access: ") # make a class to reset the user back to the main menu if value == 2: test = input("Enter Account Name to Terminate: ") input("Are You Sure You Want to Terminate " + test + "?") # make a class to reset the user back to the main menu main() You can see that in the beginning of the code i declare a dictionary in which to store the users, I've already come up with code that will ask for the user to input a name for their bank account and it'll generate a random "account number" to assign the user, the code is as follows:
#!/usr/bin/env python from time import sleep import random class CreateCustomer: @staticmethod def create_user(): def new_user() -> str: print("Welcome to The 'Create New User' Interface") sleep(0.5) x = input("Enter Name to Use for Account Access\n*Name is Case Sensitive to Access Account*: ") print(x) return x def account_generator() -> int: x = '0123456789' acctlen = 8 acctnum = ''.join(random.sample(x, acctlen)) print(acctnum) return int(acctnum) user = new_user() account_number = account_generator() return user, account_number Now my question is how can I update the dictionary I declared in the beginning of the main function with the randomly generated "account number" as the key and the account name as the value?
users[account_number]=user?