# file: App_V3.py
# Updated the code to add functionality

name = input("Hello, what's your name?: ")
# Using the var.title() function to set upper case for the first letters of entered name
print("Hello, " + name.title() + ", and welcome!")
# Taking an integer value and assigning it to the "service" variable for later use
# while making a "while" loop with an exception catching function in case the user inputs
# an alphabetical number instead of a numerical one redirecting the user to valid input

while True:
    service = input("Now please take a seat and tell me how many guests are you bringing with you tonight?: ")
    try:
        service = int(service)
        break
    except ValueError:
        print("Please tell me a number.")
# Making a condition to define if the subjects will be plural or singular
if service > 1:
    invitee = " guests"
    table = " them."
    clients = " all"
else:
    invitee = " guest"
    table = " the both of you."
    clients = " the both"
print("Oh, " + str(service) + invitee + "..., then I shall prepare a table for" + table)
menu = ["Salad", "Sandwich", "Tiramisu"]
print("In regards to your order, we have " + str(len(menu)) + " specialties today !")
# Code to accept only available choices
while True:
    choice = input("What will you begin with, " + menu[0] + ", " + menu[1] + " or " + menu[2] + " ?")
    if choice != menu[0] or choice == menu[1] or choice == menu[2]:
        print("Please tell me a valid menu item.")
    else:
        break
print("So " + choice + " for" + clients + " of you")

Tags