Nov-08-2019, 09:02 PM
Hello,
I am trying to make an ATM in the CMD with the use of Python but I have to import a module which could have any name because it is being created through user input.
I basically just want to import a module with the use of a variable.
I already have this:
I am trying to make an ATM in the CMD with the use of Python but I have to import a module which could have any name because it is being created through user input.
I basically just want to import a module with the use of a variable.
I already have this:
import os import time import importlib users = {} global username class login_system: def registration(): username = input("Select your username: ") if username in users: print("This username is already in use.") registration() elif username not in users: password = input("Select your password: ") users[username] = password save = open(f"{username}.py","w+") save.write("money = 0.00") save.close() print("Registered successfully.") login_system.logging_in() def logging_in(): username = input("Enter your username: ") if username not in users: print("Username not found.") login_system.registration() elif username in users: password = input("Enter your password: ") if password == users[username]: print("Successfully logged in.") #<-- so right here I would want to import it bank_system.options() def log_or_reg(): choice = input("Would you like to 'LOG IN' or 'REGISTER'?\n:") choice = choice.upper() if choice == 'REGISTER': os.system('cls') login_system.registration() elif choice == 'LOG IN' or choice == 'LOGIN': os.system('cls') login_system.logging_in() else: print("Wrong input, please try again.") time.sleep(2) os.system('cls') login_system.log_or_reg() class bank_system(): def options(): option = input("Do you wish to see 'BALANCE','DEPOSIT','WITHDRAW' or 'LOG OUT?'\n:") option = option.upper() if option == "LOG OUT" or option == "LOGOUT": login_system.log_or_reg() elif option == "DEPOSIT": depo_amount = input("Enter deposit amount: ") if float(depo_amount) < 0: print("You can't deposit less than 0 dollars.") elif float(depo_amount) > 0: money = money + float(depo_amount) print(money) print("Welcome to Sk4rdBank!") time.sleep(3) os.system('cls') login_system.log_or_reg()If anyone of you fantastic people could help me I would be very happy.