Documentation
Documentation
registered_accounts = []
account_pins = []
bank_balance = []
choice = None
# main loop (start)
while choice != '0':
# welcome hahahhahaahhaah pakyu k
print("|------------------------------------|")
print("| Welcome to Buguk Bank Incorporated |")
print("|------------------------------------|")
try:
print("[1] Login")
print("[2] Register")
print("[0] Exit")
choice = input("Enter your choice: ")
assert choice.isdigit() and choice in ['1', '2', '0'], "Invalid choice. Please try again"
except AssertionError as e:
print(e)
continue
# nakapili n si buguk
if choice == '1':
count = 0
while count <= 3:
try:
print("|---------------|")
print("| Account Login |")
print("|---------------|")
if not registered_accounts: # pag ala pa nakaregister
print("No registered accounts yet. Please register first.")
break
card = input("Enter your card number (include '-'): ")
pin = input("Enter your card pin (6 digits): ")
login_success = False
for i in range(len(registered_accounts)): # kaya niyo n toh
if registered_accounts[i] == card:
if account_pins[i] == pin:
print("Login Success")
while True: # pag d siya tanga maglogin
try:
print("|-----------------------|")
print("| Bank Operations |")
print("|-----------------------|")
print(f"Welcome back, {registered_accounts[i][-4::]}")
print("[1] Deposit")
print("[2] Withdraw")
print("[0] Logout")
operation = input("Enter your choice: ")
assert operation.isdigit() and operation in ['0', '1', '2'], "Invalid choice. Please try again"
if operation == '0':
break
amount = float(input("Enter amount: "))
if operation == '1':
bank_balance[i] += amount
print(f"Deposit successful. New balance: {bank_balance[i]}")
elif operation == '2':
if amount > bank_balance[i]:
raise Exception("Insufficient balance")
bank_balance[i] -= amount
print(f"Withdrawal successful. New balance: {bank_balance[i]}")
except AssertionError as e:
print(e)
continue
except Exception as e:
print(e)
continue
login_success = True
break else: # pag mali pin ahahahhahaha em
count += 1
raise Exception("Incorrect PIN")
if not login_success: # eto mali n una palang hahahahhaha
count += 1
raise Exception("Card number not found")
except Exception as e: # kaya niyo n toh igets
print(e)
print(f"({count}/3 remaining)")
if count >= 3:
print("Too many login attempts. Please try again later.")
break
continue break elif choice == '2': # ggwa siya account niya
while True:
try:
print("|----------------------|")
print("| Account Registration |")
print("|----------------------|")
for index in range(len(unregistered_accounts)):
print(f"[{index + 1}] {unregistered_accounts[index]}")
selected_card = input("Enter the number of your desired card: ")
assert selected_card.isdigit() and int(selected_card) <= len(unregistered_accounts), "Invalid choice. Make sure that the number you
have chosen is in the choices"
desired_pin = input("Enter your desired pin (must be 6 digits): ")
assert desired_pin.isdigit() and len(desired_pin) == 6, "Invalid pin. Make sure that it is numerical and is 6 digits long"
re_enter = input("Re-enter your pin: ")
assert desired_pin == re_enter, "Invalid. Pins do not match"
# add sa registered remove s unreg, promoted n sya
registered_accounts.append(unregistered_accounts[int(selected_card) - 1])
account_pins.append(desired_pin)
unregistered_accounts.pop(int(selected_card) - 1)
bank_balance.append(0)
print(f"Please note your card number: {unregistered_accounts[int(selected_card) - 1]}")
print("Account registered. You can now login your account")
break
except AssertionError as e:
print(e)
continue
basta yan, pipili siya, ung assert check niya if digit b tas kung nasa choices
pag wala, punta sita except: tas bat ganon kasi pede ka magset ng custom error message tas bakit AssertionError as e kasi pag assertion lng tas pinrint m un,
pangit output same message pero d estitik, basta yan, may continue kasi uulit siya unli try yan d nmn ako mammroblema kung tanga ung magllogin
jusko po andami neto pakyu bawal kasi function e edi sana happy happy, yan buo ng 1
try:
print("|---------------|")
print("| Account Login |")
print("|---------------|")
if not registered_accounts: # pag ala pa nakaregister
print("No registered accounts yet. Please register first.")
break
card = input("Enter your card number (include '-'): ")
pin = input("Enter your card pin (6 digits): ")
login_success = False
keri niyo n gets to, if not registered dba not t to f vice versa, pag wala laman ung registered account babalik siya dun sa una ung welcome, kasi ngaa wala pa
acounttttttttttt
next, ayan madali nlng pala yan, ung login success para lang ano alam kung pasok
yan oh dba, iterate buong loop eh tutal if same card nd same pin success yey d sha tanga
aun lang pala explanation niyan ahhahaha
emi, ung palang break diyan useful yan kasi maya explain q ahahhaha
yannnnnnnnnnn, odeba a ung ano sa welcome, last 4 digit mag didisplay dun ewan ko bala n if may dadagdag gaur, keri n name? tsaka n manonood muna ako
pipipili sya basic
assert keri niyo n igets yun
oh aun if 0 break n, dito muna sa while true, ode labas n un non, tas dba may break kanina sa for loop dun sa login kineme so mag bbreak n nmn ulit yon tas
meron pa ulit break ay d dana tsaka na to mahirap explain kelangan nakkita nio code, pass n next n
ay ayan keri niyo n yan if depo then depo
if withdraw edi withdraw tas check din if may pera pa siya hahahaha
2 except dba, tsaka na rin to hahahaa
nakapili na 2 daw
elif choice == '2': # ggwa siya account niya
while True:
try:
print("|----------------------|")
print("| Account Registration |")
print("|----------------------|")
for index in range(len(unregistered_accounts)):
print(f"[{index + 1}] {unregistered_accounts[index]}")
selected_card = input("Enter the number of your desired card: ")
assert selected_card.isdigit() and int(selected_card) <= len(unregistered_accounts), "Invalid choice. Make sure that the number you have
chosen is in the choices"
desired_pin = input("Enter your desired pin (must be 6 digits): ")
assert desired_pin.isdigit() and len(desired_pin) == 6, "Invalid pin. Make sure that it is numerical and is 6 digits long"
re_enter = input("Re-enter your pin: ")
assert desired_pin == re_enter, "Invalid. Pins do not match"
# add sa registered remove s unreg, promoted n sya
registered_accounts.append(unregistered_accounts[int(selected_card) - 1])
account_pins.append(desired_pin)
unregistered_accounts.pop(int(selected_card) - 1)
bank_balance.append(0)
print(f"Please note your card number: {unregistered_accounts[int(selected_card) - 1]}")
print("Account registered. You can now login your account")
break
except AssertionError as e:
print(e)
continue
yan pede na, bali dba meron tau unreg acc, pili sha don, tas aun gagawa siya
tas add muna sa reg acc, sa reg pin
tas remove sa unreg
add dn pala ng balance n 0 hahahah
ayon break, balik sa welcome done n
keri n
uwi n