CS50 EOF 的 PSET3 输入停止程序 Felipes Taqueria [关闭]

CS50 PSET3 input of EOF halts program Felipes Taqueria [closed]

提问人:Osman Abuna 提问时间:8/21/2023 最后编辑:Bill HilemanOsman Abuna 更新时间:8/21/2023 访问量:60

问:


这个问题是由错别字或无法再现的问题引起的。虽然类似的问题可能在这里是主题,但这个问题的解决方式不太可能帮助未来的读者。

3个月前关闭。

因此,当看到代码运行和输出所需的所有步骤时,我的代码有点正确,但是在检查时我得到了错误input of EOF halts program

这是我的代码

d = {
    "Baja Taco": 4.00,
    "Burrito": 7.50,
    "Bowl": 8.50,
    "Nachos": 11.00,
    "Quesadilla": 8.50,
    "Super Burrito": 8.50,
    "Super Quesadilla": 9.50,
    "Taco": 3.00,
    "Tortilla Salad": 8.00
}
food_total = 0.00
while True:
    x = input("Item: ").title()
    if x in d:
        food_total += d[x]
        print("Total: $", food_total, sep="")
    else:
        print(end="")

我什至尝试将代码更改为

d = {
    "Baja Taco": 4.00,
    "Burrito": 7.50,
    "Bowl": 8.50,
    "Nachos": 11.00,
    "Quesadilla": 8.50,
    "Super Burrito": 8.50,
    "Super Quesadilla": 9.50,
    "Taco": 3.00,
    "Tortilla Salad": 8.00
}
food_total = 0.00
while True:
    try:
        x = input("Item: ").title()
        if x in d:
            food_total += d[x]
            print("Total: $", food_total, sep="")
        else:
            print(end="")
    except EOFError:
        pass

但没有任何区别

Python 计算机科学 CS50 EOF

评论


答: 暂无答案