In this chapter, you learned how to create lists and tuples that contain multiple data values under one variable name. You also learned how to iterate over those data values with "for" loops and create "while" loops that continue so long as a condition is True.

You are going to use all those skills to create the "BurgerCastle" fast food ordering system! Your "BurgerCastle" program will show the customer a menu, take individual items in their order, and then print out a description of each item in the order.

The sample run below demonstrates how the program should work.

Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: burger
Enter Item: soda
Enter Item: pizza
Sorry, we don't sell pizza
Enter Item: fries
Enter Item: quit

Order complete; you are having:
Half-pound burger
Diet root beer
Large fries
Thanks for visiting Burger Castle!
Detailed Program Requirements
Write your program by carefully following the steps listed below. For the best grade, please match the expected output exactly (including correct spelling and case of all messages).

Start with a comment that contains your student name
Initialize a tuple named validOrders with the contents "burger","fries","salad","soda","milkshake". This tuple contains the allowed strings that a customer can type to add an item to the order.
Initialize a tuple named itemDescriptions with the contents: "Half-pound burger","Large fries","Side salad", "Diet root beer", "Chocolate shake". This tuple contains a description of each of the allowed orders.
Note that values in the validOrders and itemDescriptions tuples are arranged so matching items and descriptions will always have the same numeric index value. This means if you find the index value for a validOrders element like "fries" (index 1), you can get the description by reading the value at the same index from the itemDescriptions.

Matching tuple index values

Next, initialize an empty list named order. This list will grow as customers enter each item they want to buy.
Next, print three messages to the screen:
"Welcome to Burger Castle"
"Menu: " (and then the list of validOrders)
"Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done."
Checkpoint: If you run your program now, you should see the first three lines displayed as shown below.
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Next, you need to write a "while" loop that will prompt the customer for an item, continuing to do so until the customer wants to quit. If the item is valid, it should be added to the orders list, otherwise, an error message is printed. We recommend using the "do-while" style, where the loop will prompt the user once at the top, break out of the loop if the user is done, and otherwise process the item at the end of the loop. However, you are free to write any "while" loop that meets the program's input and output requirements.

The following tasks should be completed by your "while" loop. The exact order and logic will depend on your chosen "while" loop details.

Prompt the user for input() with "Enter Item: " and store the result in the item variable.
If the item is an empty string ("") or the value "quit", the loop should end without adding that item to the order list.
If the item is present in the validOrders tuple, append that item to the end of the order list.
Else if the item is not in the validOrders, print a message to the screen that says "Sorry, we don't sell " + item.


Checkpoint: If you run your program now, you should be able to successfully enter any valid item on the menu and should receive the correct error message if you enter an item that is not on the menu.
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: burger
Enter Item: soda
Enter Item: pizza
Sorry, we don't sell pizza
Enter Item: fries
Enter Item: quit
Next, after the "while" loop, add some print() statements to display a blank line and the phrase "Order complete; you are having:" to the screen. The blank line and message should appear after the user exits the "while" loop.
Enter Item: quit

Order complete; you are having:
Finally, you need to write a "for" loop over each of the items in the order list. Find the index value of that item in the validOrders tuple, and then read and print the matching description of that item from the itemDescriptions tuple.

Start a "for" loop where the loop variable name is item and you are iterating over all the values in the order list.
Use the index() function to search the validOrders tuple for the current item. Store the resulting numeric index in a variable called index.
Read the data at that numeric index from the itemDescriptions tuple and store it in a variable named description. Remember, you can use the square brackets notation itemDescriptions[index] to read a value from a specific index position in a list or tuple.
Print the description to the screen
After the "for" loop is done, print the final message "Thanks for visiting Burger Castle!".


Checkpoint: Your program should now be fully functional and print the correct descriptions for each of the items the customer ordered. Test your program with each of the suggested input combinations shown below.


Starting Code
We are not providing any starting code for this program. It is important for you to practice turning detailed project requirements into a working program on your own. That way, when you have an idea for your own program, you won't need any help writing it from scratch!

Note that we suggested periodic "checkpoints" in your work to verify one section of code works before moving to the next section. This approach is important for software engineers! It is much easier to write and test programs in small chunks. If you spend lots of time writing a large program and then try to run it all at once, you will likely have a harder time finding and fixing problems that could be anywhere in your code.


Activity Results
The following example runs demonstrate some possible input and output combinations. Be sure your program matches the desired output exactly in each case for the best grade (double-check spelling, capitalization, etc.). You should be able to test with other combinations of input and get similar outputs, based on your understanding of the program behavior.

Test #1 - Items: quit (no items - just quit right away)
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: quit

Order complete; you are having:
Thanks for visiting Burger Castle!
Test #2 - Items: burger, quit
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: burger
Enter Item: quit

Order complete; you are having:
Half-pound burger
Thanks for visiting Burger Castle!
Test #3 - Items: fries, "" (empty string)
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: fries
Enter Item:

Order complete; you are having:
Large fries
Thanks for visiting Burger Castle!
Test #4 - Items: burger, soda, pizza, quit
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: burger
Enter Item: soda
Enter Item: pizza
Sorry, we don't sell pizza
Enter Item: quit

Order complete; you are having:
Half-pound burger
Diet root beer
Thanks for visiting Burger Castle!
Test #5 - Items: fries, milkshake, burger, soda, salad, quit
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: fries
Enter Item: milkshake
Enter Item: burger
Enter Item: soda
Enter Item: salad
Enter Item: quit

Order complete; you are having:
Large fries
Chocolate shake
Half-pound burger
Diet root beer
Side salad
Thanks for visiting Burger Castle!
Test #6 - Items: candy, candy, burger, burger, soda, soda, quit
Welcome to Burger Castle
Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')
Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.
Enter Item: candy
Sorry, we don't sell candy
Enter Item: candy
Sorry, we don't sell candy
Enter Item: burger
Enter Item: burger
Enter Item: soda
Enter Item: soda
Enter Item: quit

Order complete; you are having:
Half-pound burger
Half-pound burger
Diet root beer
Diet root beer
Thanks for visiting Burger Castle!
.

# BurgerCastle Ordering System

# Step 1: Initialize Variables and Lists
validOrders = ("burger", "fries", "salad", "soda", "milkshake")
itemDescriptions = ("Half-pound burger", "Large fries", "Side salad", "Diet root beer", "Chocolate shake")
order = []

# Step 2: Print Welcome Messages
print("Welcome to Burger Castle")
print("Menu: ", validOrders)
print("Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.")

# Step 3: Prompt the Customer for Each Item
while True:
item = input("Enter Item: ")
if item == "" or item == "quit":
break
elif item in validOrders:
order.append(item)
else:
print("Sorry, we don't sell " + item)

# Step 4: Print Order Complete Message
print()
print("Order complete; you are having:")

# Step 5: Print Item Descriptions
for item in order:
index = validOrders.index(item)
description = itemDescriptions[index]
print(description)

# Step 6: Print Closing Message
print("Thanks for visiting Burger Castle!")

Without the word append

# BurgerCastle Ordering System

# Step 1: Initialize Variables and Lists
validOrders = ("burger", "fries", "salad", "soda", "milkshake")
itemDescriptions = ("Half-pound burger", "Large fries", "Side salad", "Diet root beer", "Chocolate shake")
order = []

# Step 2: Print Welcome Messages
print("Welcome to Burger Castle")
print("Menu: ", validOrders)
print("Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.")

# Step 3: Prompt the Customer for Each Item
while True:
item = input("Enter Item: ")
if item == "" or item == "quit":
break
elif item in validOrders:
order += [item]
else:
print("Sorry, we don't sell " + item)

# Step 4: Print Order Complete Message
print()
print("Order complete; you are having:")

# Step 5: Print Item Descriptions
for item in order:
index = validOrders.index(item)
description = itemDescriptions[index]
print(description)

# Step 6: Print Closing Message
print("Thanks for visiting Burger Castle!")

File "BurgerCastle.py", line 13

break:
^
SyntaxError: invalid syntax

I apologize for the mistake. The correct syntax to break out of a loop in Python is simply `break`, without the colon `:`. Here's the corrected code:

```python
# BurgerCastle Ordering System

# Step 1: Initialize Variables and Lists
validOrders = ("burger", "fries", "salad", "soda", "milkshake")
itemDescriptions = ("Half-pound burger", "Large fries", "Side salad", "Diet root beer", "Chocolate shake")
order = []

# Step 2: Print Welcome Messages
print("Welcome to Burger Castle")
print("Menu: ", validOrders)
print("Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.")

# Step 3: Prompt the Customer for Each Item
while True:
item = input("Enter Item: ")
if item == "" or item == "quit":
break
elif item in validOrders:
order += [item]
else:
print("Sorry, we don't sell " + item)

# Step 4: Print Order Complete Message
print()
print("Order complete; you are having:")

# Step 5: Print Item Descriptions
for item in order:
index = validOrders.index(item)
description = itemDescriptions[index]
print(description)

# Step 6: Print Closing Message
print("Thanks for visiting Burger Castle!")
```

Please try running the code now.

File "BurgerCastle.py", line 13

break
^
SyntaxError: 'break' outside loop

Apologies for the mistake once again. The issue is that the `break` statement needs to be inside the `while` loop. Here's the corrected code:

```python
# BurgerCastle Ordering System

# Step 1: Initialize Variables and Lists
validOrders = ("burger", "fries", "salad", "soda", "milkshake")
itemDescriptions = ("Half-pound burger", "Large fries", "Side salad", "Diet root beer", "Chocolate shake")
order = []

# Step 2: Print Welcome Messages
print("Welcome to Burger Castle")
print("Menu: ", validOrders)
print("Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.")

# Step 3: Prompt the Customer for Each Item
while True:
item = input("Enter Item: ")
if item == "" or item == "quit":
break
elif item in validOrders:
order.append(item)
else:
print("Sorry, we don't sell " + item)

# Step 4: Print Order Complete Message
print()
print("Order complete; you are having:")

# Step 5: Print Item Descriptions
for item in order:
index = validOrders.index(item)
description = itemDescriptions[index]
print(description)

# Step 6: Print Closing Message
print("Thanks for visiting Burger Castle!")
```

Please try running the code again.

FAILED: Output Test 10: Test Items: burger, quit (-10.0)

Student Output Expected Output
Welcome to Burger Castle

Welcome to Burger Castle

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Enter Item: burger

Enter Item: burger

Enter Item: quit

Order complete; you are having:

Order complete; you are having:

Half-pound burger

Thanks for visiting Burger Castle!

Thanks for visiting Burger Castle!

FAILED: Output Test 11: Test Items: fries, "" (-10.0)
Student Output Expected Output
Welcome to Burger Castle

Welcome to Burger Castle

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Enter Item: fries

Enter Item: fries

Enter Item:

Order complete; you are having:

Order complete; you are having:

Large fries

Thanks for visiting Burger Castle!

Thanks for visiting Burger Castle!

FAILED: Output Test 12: Test Items: burger, soda, pizza, quit (-10.0)
Student Output Expected Output
Welcome to Burger Castle

Welcome to Burger Castle

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Enter Item: burger

Enter Item: burger

Enter Item: soda

Enter Item: pizza

Sorry, we don't sell pizza

Enter Item: quit

Order complete; you are having:

Order complete; you are having:

Half-pound burger

Diet root beer

Thanks for visiting Burger Castle!

Thanks for visiting Burger Castle!

FAILED: Output Test 13: Test Items: fries, milkshake, burger, soda, salad, quit (-10.0)
Student Output Expected Output
Welcome to Burger Castle

Welcome to Burger Castle

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Enter Item: fries

Enter Item: fries

Enter Item: milkshake

Enter Item: burger

Enter Item: soda

Enter Item: salad

Enter Item: quit

Order complete; you are having:

Order complete; you are having:

Large fries

Chocolate shake

Half-pound burger

Diet root beer

Side salad

Thanks for visiting Burger Castle!

Thanks for visiting Burger Castle!

FAILED: Output Test 14: Test Items: candy, candy, burger, burger, soda, soda, quit (-10.0)
Student Output Expected Output
Welcome to Burger Castle

Welcome to Burger Castle

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Menu: ('burger', 'fries', 'salad', 'soda', 'milkshake')

Please enter each item in your order. Press 'Enter' or type 'quit' on an empty line when done.

Enter Item: candy

Sorry, we don't sell candy

Enter Item: candy

Enter Item: candy

Sorry, we don't sell candy

Enter Item: burger

Enter Item: burger

Enter Item: soda

Enter Item: soda

Enter Item: quit

Order complete; you are having:

Order complete; you are having:

Half-pound burger

Half-pound burger

Diet root beer

Diet root beer

Thanks for visiting Burger Castle!

Thanks for visiting Burger Castle