所以我刚开始研究这个来练习我的递归经验。我这里有我的代码,出于某种原因,它只允许我使用其中的取款部分,而不允许我使用存款:
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()
请让我知道我的错误在这里!你知道吗
您应该更改:
收件人:
对
deposit
也是这样。你知道吗相关问题 更多 >
编程相关推荐