Advertisement
skip420

ATM_Withdraw

Sep 12th, 2021
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.99 KB | None | 0 0
  1. def main():
  2.     pinCode = ["1234", "1999", "2424", "1985", "5555"] #data of the account holders
  3.     accountHoldersName = ["Timothy Scott Mercurio,"]
  4.     accountNumber = ['1353', '199281', "182838", "185597", "667432"]
  5.     balance = [567000, 21873, 2341871, 275638, 91820]
  6.  
  7.     flag = False
  8.     for i in range (0,999999999): #so the loop runs almost infinit many times
  9.         print("""
  10.    \t\t=== Welcome To Simple ATM System ===
  11. """)
  12.         inputName = input("Enter Your Name: ")
  13.         inputName = inputName.lower()
  14.         inputPin = 0000 #if pin is wrong it will be use as this is assigned before referance.
  15.         index = 0 #if pin is wrong it will be use as this is assigned before referance.
  16.         for name in accountHoldersName:
  17.             count = 0
  18.             if name == inputName:
  19.                 index = count #index of anme is stored and if the pin of that index is same user will be given access to the account.
  20.                 inputPin = input("\nEnter Pin Number: ")
  21.             count += 1
  22.  
  23.         if inputPin == pinCode[index]:
  24.             flag = True
  25.         else:
  26.             print("Invalid data.")
  27.             flag = False
  28.             continue
  29.         if flag == True:
  30.             print("\nYour account number is: ",accountNumber[index])
  31.             print("Your account balance is: Rs.", balance[index])
  32.             drawOrDeposite = input("\nDo you want to draw or deposit cash (draw/deposite/no): ")
  33.             if drawOrDeposite == "draw":
  34.                 amount = input("\nEnter the amount you want to draw: ")
  35.                 try: #Exception handling
  36.                     amount = int(amount)
  37.                     if amount > balance[index]:
  38.                         raise
  39.                 except:
  40.                     print("invalid amount.")
  41.                     continue
  42.                 remainingBalalnce = balance[index] - amount #subtracting the drawed amount.
  43.                 balance.remove(balance[index]) #removing the old ammount from the list and adding the new list after draw.
  44.                 balance.insert(index,remainingBalalnce)
  45.                 availableBalance = print("\nYour available balance is: ",remainingBalalnce)
  46.             elif drawOrDeposite == "deposit":
  47.                 amount = input("Enter the amount you want to deposite: ")
  48.                 try:
  49.                     amount = int(amount)
  50.                     if amount > balance[index]:
  51.                         raise
  52.                 except:
  53.                     print("invalid amount.")
  54.                     continue
  55.                 remainingBalalnce = balance[index] + amount #adding the deposited amount.
  56.                 balance.remove(balance[index])#removing the old ammount from the list and adding the new list after draw.
  57.                 balance.insert(index,remainingBalalnce)
  58.                 availableBalance = print("Your available balance is: ",remainingBalalnce)
  59.             print("\n\nThank you for using this Simple ATM System. \n  Brought To You By code-projects.org")
  60.  
  61. main()
  62.  
  63.  
  64.  
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement