Python core 43.2 the command "except:" does not work?
My code is below: coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"] choice = int(input()) try: a = len(coffee) b = a-1 if 0<=choice<=b: print(coffee[choice]) # your code goes here except: print('Invalid number') # and here finally: print('Have a good day') When entering a number between 0 and 4, everything is fine. But if you enter a different number, it just prints what should be printed after the "finally:" I went through the task using code that is written below, but I would like to know what my mistake. Thanks. coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"] choice = int(input()) a = len(coffee) b = a-1 if 0<=choice<=b: print(coffee[choice]) else: print('Invalid number') print('Have a good day')