Here is the code:
# Write a program that asks the user how many people
# are in their dinner group. If the answer is more than eight, print a message saying
# they’ll have to wait for a table. Otherwise, report that their table is ready.
people = input("How many people will you be having in your dinner group? ")
people = int(people)
if people > 8:
print(input("We'll have to put you on a short wait, is that okay?" ))
if 'yes':
print("Okay, we will call your table in the next 15 minutes.")
else:
print("Okay, we will see you another night, then. Thank you for stopping by.")
else:
print("Perfect! Right this way; follow me.")
I'm not sure if my 2nd "if" statement is correct, because I want to make it so that if someone says "yes" and anything else in their sentence, or "yes" later in their sentence, then it will print that ("Okay, we will call your table in the next 15 minutes.") print statement.
Currently, if I type anything,(after answering the first question with any number above 8) even "no" it will still print the ("Okay, we will call your table in the next 15 minutes.") statement. I'd like the same thing for the "yes" explained above to happen for the "no" answer as well.
I tried putting 'yes' after the if, but I feel like I am missing something. Same for the 'else'.
CodePudding user response:
You have to store the result of your input in a variable:
choice = input("We'll have to put you on a short wait, is that okay?" )
if choice == 'yes':
# Do something
else:
# Do something else
CodePudding user response:
You aren't saving the value of the response to be able to check it in your second if
:
if people > 8:
response = input("We'll have to put you on a short wait, is that okay?")
if response == 'yes':
print("Okay, we will call your table in the next 15 minutes.")
else:
print("Okay, we will see you another night, then. Thank you for stopping by.")
else:
print("Perfect! Right this way; follow me.")