Skip to content

Commit b06e294

Browse files
committed
Fixed methods not evaluating
1 parent 3c05bd0 commit b06e294

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lab-11/atm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# TODO: validate if id given is an integer
22
from account import Account
33

4+
# for i in range(1, 9):
5+
# eval(f"account_{i} = Account({i}, 100)")
6+
47
account_1 = Account(1, 100)
58
account_2 = Account(2, 100)
69
account_3 = Account(3, 100)
@@ -37,14 +40,13 @@ def main_menu(id):
3740
withdraw_amount = float(
3841
prompt("Enter the amount of money you would like to withdraw: "))
3942
eval(f"account_{id}.withdraw({withdraw_amount})")
40-
print(f"${withdraw_amount} was withdrawed successfully\nYour new balance is {account_{id}.get_balance()}")
43+
print(f"${withdraw_amount} was withdrawed successfully\nYour new balance is {eval('account_'+ id + '.get_balance()')}")
4144
get_id()
4245
elif (selection == 3):
4346
deposit_amount = float(
4447
prompt("Enter the amount of money you would like to deposit: "))
4548
eval(f"account_{id}.deposit({deposit_amount})")
46-
print(f"${deposit_amount} was deposited successfully\n\
47-
Your new balance is {account_{id}.get_balance()}")
49+
print(f"${deposit_amount} was deposited successfully\nYour new balance is {eval('account_' + id + '.get_balance()')}")
4850
get_id()
4951
elif (selection == 4):
5052
exit()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy