[Tutor] looping - beginner question
Rafael Knuth
rafael.knuth at gmail.com
Thu Mar 2 08:42:58 EST 2017
I wrote a program that is supposed to take orders from customers in a bar.
If the desired drink is available, the customer will be served. If
not, he will be informed that the drink is not available. This is what
I wrote:
bar = ["beer", "coke", "wine"]
customer_order = input("What would you like to drink, dear guest? ")
for drink in bar:
if customer_order != drink:
print ("Sorry, we don't serve %s." % customer_order)
else:
print ("Sure, your %s will be served in a minute!" % customer_order)
What I want the program to do is to "silently" loop through the list
of drinks and to print the correct answer. Instead, it loops through
each item on the list like this:
>>>
== RESTART: C:/Users/Rafael/Documents/01 - BIZ/Python/Python Code/PPC_4.py ==
What would you like to drink, dear guest? coke
Sorry, we don't serve coke.
Sure, your coke will be served in a minute!
Sorry, we don't serve coke.
>>>
More information about the Tutor
mailing list