I'm relatively new to coding and im super confused at why my code is not working it looks like it should but it doesn't. it first asks for the amount of seats required and then asks for there name then there food choice. it appends the names fine but it only appends the first food choice and nothing after that. I'm not getting any errors anything.
Here's my code:
people = []
working = False
seatNum = input("How many seats do you need: ")
while (not seatNum.isnumeric()):
print("Invalid")
seatNum = input("How many seats do you need: ")
print("Mince pie = 1, Chocolate coins = 2, Apple pie = 3")
seatNum = int(seatNum)
for i in range(seatNum):
Nam = input("Enter name: ")
people.append(Nam)
choice = input("Enter your choice: ")
while (working == False):
while (not choice.isnumeric()):
print("Invalid")
choice = input("Enter your choice: ")
choice = int(choice)
if choice == 1 or choice == 2 or choice == 3:
working = True
else:
print("Enter number between 1-3")
choice = input("Enter your choice: ")
if choice == 1:
people.append("Mince Pie")
elif choice == 2:
people.append("Chocolate coins")
elif choice == 3:
people.append("Apple pie")
print(people)
That's my code is super messy but its not done. here's the output:
How many seats do you need: 3
Mince pie = 1, Chocolate coins = 2, Apple pie = 3
Enter name: a
Enter your choice: 1
Enter name: b
Enter your choice: 2
Enter name: c
Enter your choice: 3
['a', 'Mince Pie', 'b', 'c']
and here is the desired output:
How many seats do you need: 3
Mince pie = 1, Chocolate coins = 2, Apple pie = 3
Enter name: a
Enter your choice: 1
Enter name: b
Enter your choice: 2
Enter name: c
Enter your choice: 3
['a', 'Mince Pie', 'b', 'Chocolate coins', 'c', 'Apple pie']
Any and all help is appreciated. Thanks in Advance
Talia.
workingvariable, usewhile True:and then usebreakwhen you want to get out of the loop.