Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c05bd0

Browse files
committed
Elif instead of else if
1 parente1aba9a commit3c05bd0

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎lab-11/atm.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
account_8=Account(8,100)
1212
account_9=Account(9,100)
1313

14+
1415
defget_id():
1516
globalid
1617
id=input("Enter an account id")
@@ -20,6 +21,7 @@ def get_id():
2021
print("Invalid id, try again!")
2122
get_id()
2223

24+
2325
defmain_menu(id):
2426
print("Main Menu\n\
2527
1: check balance\n\
@@ -31,19 +33,23 @@ def main_menu(id):
3133
if (selection==1):
3234
print(eval(f"account_{id}.get_balance()"))
3335
get_id()
34-
elseif (selection==2):
35-
withdraw_amount=float(prompt("Enter the amount of money you would like to withdraw: "))
36+
elif (selection==2):
37+
withdraw_amount=float(
38+
prompt("Enter the amount of money you would like to withdraw: "))
3639
eval(f"account_{id}.withdraw({withdraw_amount})")
3740
print(f"${withdraw_amount} was withdrawed successfully\nYour new balance is{account_{id}.get_balance()}")
3841
get_id()
39-
elseif (selection==3):
40-
deposit_amount=float(prompt("Enter the amount of money you would like to deposit: "))
42+
elif (selection==3):
43+
deposit_amount=float(
44+
prompt("Enter the amount of money you would like to deposit: "))
4145
eval(f"account_{id}.deposit({deposit_amount})")
42-
print(f"${deposit_amount} was deposited successfully\nYour new balance is{account_{id}.get_balance()}")
46+
print(f"${deposit_amount} was deposited successfully\n\
47+
Your new balance is{account_{id}.get_balance()}")
4348
get_id()
44-
elseif (selection==4):
49+
elif (selection==4):
4550
exit()
46-
else:
51+
else:
4752
print("Error")
4853

54+
4955
get_id()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp