首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >期望表达式ATM

期望表达式ATM
EN

Stack Overflow用户
提问于 2022-10-05 20:59:21
回答 1查看 54关注 0票数 -2

我和youtube的视频一起使用python跟踪到ATM上,我得到了预期的表达。我不知道怎么修理它。第32、37和40行。

在这里输入图像描述

EN

回答 1

Stack Overflow用户

发布于 2022-10-05 21:07:58

您不能在elif之后使用else。这是因为else将捕获所有剩余的案例。缩进,即行前的空格或制表符在Python中非常重要。

我认为你想写的是:

代码语言:javascript
复制
balance = 1000
print("""
Welcome to Dutch Bank
Choose Transaction
1) BALANCE
2) WITHDRAW
3) DEPOSIT
4) EXIT
""")

while True:
    option = int(input("Enter Transaction"))
    if option == 1:
        print ("Your Balance is", balance)
        anothertrans = input("Do You Want to make another Transaction? Yes/No: ")
        if anothertrans == "YES":
            continue
        else:
            break
    elif option == 2:
        withdraw = float(input("Enter Amount To Withdraw"))

        if (balance > withdraw):
            total = balance - withdraw
            print("Success")
            print("Your New Balance is: ",total)
        else:
            print("Insufficient Balance")

    elif option == 3:
        deposit = float(input("Enter Amount To Deposit"))
        totalbalance = balance + deposit
        print("Sucess")
        print("Total Balance Now is: ", totalbalance)

    elif option == 4:
        print("Thank You ForBanking With Dutch Bank")
        exit()
    else:
        print ("No selected Transaction")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73966279

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档