I'm studying CS50p and the tutor says it's best practice to have as few lines as possible, ideally one, in a Try, but I really struggle to do this.
How could I write the following code so that I only try the input?
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