我正在学习CS 50 p,导师说最好的做法是在Try中尽可能少地使用台词,最好是一句台词,但我真的很难做到这一点.
如何才能编写以下代码以便仅try 输入?
while True:
try:
# How to have just 1 line in try??
order = input("Order: ").title().strip()
if order in menu:
price += menu[order]
print(f"Total: ${price}")
except (EOFError, KeyError):
break