首页 > 解决方案 > 我想知道如何做到这一点,以便如果条件结束,代码在存款后不会停止,我该怎么做?(PYTHON)

问题描述

我想知道如何做到这一点,以便在 DEPOSIT if 条件结束后代码不会停止,而是 intead 循环回输入。我怎样才能在 Python 中做到这一点?

这是我的代码:

print("Welcome to Doge Bank") 
print("How much money would you like to start with?") 
balance = int(input()) 
print("Great! You can type DEPOSIT to DEPOSIT money, BAL to check your BALANCE and WITHDRAW to WITHDRAW money") 
operation = input() 


if operation == "DEPOSIT": 
    print("You have started a deposit operation, say Y to continue") 
    confirm = input() 
    if confirm == "Y": 
        print("How much would you like to deposit?") 
        depositNum = int(input()) 
        balance = balance - depositNum
        print("You have deposited", depositNum, "| Your current balance is", balance)

标签: python

解决方案



推荐阅读