【发布时间】:2015-05-10 01:12:14
【问题描述】:
所以我刚刚开始研究这个以练习我的递归经验。我在这里有我的代码,出于某种原因,它只允许我使用其中的提款部分,而不是存款:
def recursive(n):
print("You have $", n, "In the bank!")
option = (input("Do you want to withdraw or deposit?"))
if option == "withdraw" or "Withdraw":
withdraw = int(input("How much do you want to withdraw from your account?"))
recursive(n - withdraw)
elif option == "deposit" or "Deposit":
deposit = int(input("How much do you want to deposit?"))
recursive(n + deposit)
else:
print("Not a valid option!")
print("Shutting Down!")
def money(n):
if n < 0:
print("You are out of money!")
def main():
recursive(100)
main()
请在这里告诉我我的错误!
【问题讨论】:
-
@QPaysTaxes 即使我输入了存款,它也只会让我做提款部分
-
未来,您需要将所有相关信息放入问题本身。放在 cmets 中还不错,但是放在一个地方会更整洁。