小白求助 python代码

#演示列表方法
scores = []
choice = None

while choice != “0”:

print("""
                       High Scores

                       0 - Exit
                       1 - Show Score
                       2 - Add a Score
                       3 - Remove a Score
                       4 - Sort Scores

                       """
      )

choice = input("Choice: ")
print()

#退出
if choice == “0”:
print(“Good-bye.”)
#列出最高得分
elif choice == “1”:
print(“High Scores”)
for score in scores:
print(score)
elif choice == “2”:
score = int(input("What score did you get?: "))
scores.append(score)
#删除一个得分
elif choice == “3”:
score = int(input(“Remove which score?: “))
if score in scores:
scores.remove(score)
else:
print(score, “isn’t in the high scores list.”)
#对分数进行排序
elif choice == “4”:
scores.sort(reverse=True)
#其他未知选项
else:
print(“Sorry,but”,choice,“isn’t a valid choice.”)
input(”\n\nPress the enter key to exit.”)

照着书上敲得,
在这里插入图片描述
这里出现错误,不理解,求解答,多谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值