9/11/22

Problem 2 - Cafe menu

 Write a program that first displays a simple cafe menu (see example below), asks the user to enter the number of a choice, and either prints the appropriate action OR prints an error message that their choice was not valid.


Example output:


1. Soup and salad


2. Pasta with meat sauce


3. Chef's special


Which number would you like to order? 2


One Pasta with meat sauce coming right up!


Another example output:


1. Soup and salad


2. Pasta with meat sauce


3. Chef's special


Which number would you like to order? 5


Sorry, that is not a valid choice

print("""


1. Soup and salad


2. Pasta with meat sauce


3. Chef's special


""")


 


m = ['Soup and salad', 'Pasta with meat sauce', 'Chef\'s special']


 


try:


    x = int(input("What is your order: "))


    if 0 < x < 3:


        print('one ' + m[x] + ' coming right up!!!')


    else:


        raise ValueError


except:


    print('Sorry, that is not a valid choice')        


 


 

Blog Archive