语法错误,无法弄清楚原因(第 17 行)

Syntax Error, Cant figure out why(Line 17)

b。创建一个模拟简单储蓄账户模拟的程序。首先向用户询问初始余额(必须至少为 $100 且小于 $400,000)。只要用户想继续允许他们进行存款和取款——不要透支!当用户完成后,输出最终余额。 (建议……使用类似以下的菜单: 1. 存款 2.提款 3. 退出 )

balance = int(input("Enter initial balance: $ "))

while balance <= 100 or balance >= 400000:
    print ("Invalid Amount!")
    balance = int(input("Ener valid amount: $ "))

deposit = 0
withdraw = 0

if balance >= 100 and balance <= 400000:
    while ans != 3: 
        print("""
    1. Deposit
    2. Withdrawal
    3. Quit
    """)
ans = int(input("What would you like to do? Please enter the appropriate     number. "))
if ans == 1:
    deposit = int(input("\n How much would you like to deposit: $")
    balance = balance + deposit
elif ans == 2:
    withdraw = int(input("\n How much would you like to withdraw: $")
    if (balance - withdraw) < 0
        withdraw = int(input("\n Tried to withdraw too much! How much would  you like to withdraw: $")
        balance = balance - withdraw
elif ans == 3:
print("Your final balance is %d" %balance.)

您在第 16 行缺少一个“)”。

您在上一行中缺少 ),您需要:

if ans == 1:
deposit = int(input("\n How much would you like to deposit: $"))

还有一个:

withdraw = int(input("\n How much would you like to withdraw: $"))

然后是尾部 ::

if (balance - withdraw) < 0:

还有一个 ) 再往下:

    if (balance - withdraw) < 0
        withdraw = int(input("\n Tried to withdraw too much! How much would  you like to withdraw: $"))

然后是 % 之后的 space(并去掉 .):

print("Your final balance is %d" % balance)