Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- balance = "%.2f" % round(random.uniform(1,1000),2)
- save = 0
- attempt = 1
- database = []
- def getPassword(x):
- loop = 1
- while loop == 1:
- global attempt
- while attempt == 1:
- password = input("Enter Password: ")
- while len(password) > 8 or len(password) < 6:
- password = input("Error. Password must be 6-8 characters. Try again: ")
- else:
- attempt = attempt + 1
- while attempt == 2:
- secondPassword = input("Re-Enter Password: ")
- if secondPassword == password:
- print("Registration sucessful.")
- attempt = 1
- return password
- else:
- print("Error. Passwords do not match.")
- attempt = 1
- def changePassword():
- global save
- global database
- looping = 1
- success = 0
- oldpword = input("\nPlease enter your old password: ")
- while looping == 1:
- if oldpword == database[save][1]:
- newpword = input("Please enter your new password: ")
- redopword = input("Please enter your password again: ")
- while newpword != redopword:
- redopword = input("Passwords do not match. Try again:")
- database[save][1] = redopword
- success = 1
- break
- looping -= 1
- while oldpword != database[save][1] and success != 1:
- oldpword = input("Incorrect password. Try again: ")
- def getUsername():
- loop = 1
- global database
- while loop == 1:
- username = input("\nEnter your Username: ")
- if len(database) == 1:
- while username == database[0][0]:
- username = input("Username taken. Try again: ")
- else:
- for counter in range(len(database)):
- while username == database[counter][0]:
- username = input("Username taken. Try again: ")
- return username
- def getMaster():
- global database
- username = input("Enter your Master Username: ")
- password = input("Enter your Master Password: ")
- database.append([username,password,"%.2f" % round(random.uniform(1,1000),2)])
- def Login():
- global save
- success = 0
- username = input("\nPlease enter your Username: ")
- for counter in range(0,len(database)):
- if username == database[counter][0]:
- save = counter
- success = 1
- if username != database[counter][0] and success != 1:
- print("Username not found.")
- if success == 1:
- password = input("Please enter your Password: ")
- logged = 0
- while logged == 0:
- if password == database[save][1]:
- print("\nSucessful login.")
- logged += 1
- return logged
- else:
- while password != database[save][1]:
- password = input("Incorrect password. Try again: ")
- def LoggedIn():
- global masterloop
- global database
- global save
- balance = database[save][2]
- loop = 1
- while loop == 1:
- print("\nWhich of the following would you like to do?")
- print("\nA) View current balance")
- print("B) Deposit cash")
- print("C) Withdraw cash")
- print("D) Change your password")
- choice = input("").lower()
- if choice == "a":
- print("\nYour current account balance is:")
- print(" £"+str(balance))
- elif choice == "b":
- depamount = float(input("\nHow much would you like to deposit? "))
- print("Processing..")
- balance = float(balance) + depamount
- print("\nYour new current account balance is:")
- print(" £"+str(balance))
- elif choice == "c":
- withamount = float(input("\nHow much would you like to withdraw? "))
- print("Processing..")
- while withamount > float(balance):
- print("\nYou do not have enough money.")
- print("Your current account balance is:")
- print(" £"+str(balance))
- withamount = float(input("\nPlease enter how much you would like to withdraw now: "))
- balance = float(balance) - withamount
- print("Your new current account balance is:")
- print(" £"+str(balance))
- elif choice == "d":
- changePassword()
- continuing = input("\nWould you like to continue? ").lower()
- if continuing == "yes":
- continue
- else:
- break
- getMaster()
- masterloop = 1
- while masterloop == 1:
- choice = input("\nWould you like to login, create a new account or exit?").lower()
- if choice == "login":
- logged = Login()
- if logged == 1:
- LoggedIn()
- elif choice == "exit":
- masterloop -= 1
- else:
- username = getUsername()
- password = getPassword(attempt)
- database.append([username,password,"%.2f" % round(random.uniform(1,1000),2)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement