import time
#Initializing Variables
currentMoney = 0
depositedMoney = 0
takenMoney = 0
#Main Fucntion which shows when the program starts
def Main():
while True:
userChoice = input("Welcome to the ATM Organizer. To Preceed Enter 1 To Close Enter 0")
if userChoice == 1:
Atm()
elif userChoice == 0:
print("Thank you.Good Bye!")
break
def Atm():
Handling Invalid Inputs
while True:
try:
atm = int(input("Welcome Inside The ATM , To See your money , Type '1' , To put money to the cash machine , Type '2' , To take money out of the ATM , Type '3' , To Exit the ATM , Type '0' ."))
except ValueError:
print("You didn't choose what was given!")
continue
Input Choices
if (atm == 0):
Main()
elif (atm == 1):
print("You Have ",currentMoney," Inside your account.")
break
elif (atm == 2):
money = int(input("How Much money do you want to deposit? "))
depositedMoney+=money
currentMoney=depositedMoney
print("You Have ",currentMoney," Inside Your Account")
break
elif (atm == 3):
while True:
takeMoney = int(input("How much money do you want to take? "))
if (takeMoney > currentMoney):
print("You don't have that value.")
continue
else:
print("LOADING...")
time.sleep(3)
takenMoney+=takeMoney
print("You've taken ",takenMoney," , You now have "(currentMoney-takenMoney," In your account")
break
Main()
每當我嘗試運行它時,它突出顯示上面的「break」,當我刪除它時,彈出另一個錯誤,這是最後一個代碼中的「Main()」,並且「它一直這樣做......我不知道這裏有什麼問題,我嘗試了幾乎所有的東西,但它仍然不想工作
我希望我能找到答案。
問題尋求幫助調試(**「?爲什麼不是這個代碼工作」 **)必須包括所期望的行爲,*一個特定的問題或錯誤*和*的在問題本身**中重現它的最短代碼*。沒有**明確問題陳述**的問題對其他讀者沒有用處。請參閱:[如何創建最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。 – MattDMo