# Define your functions
def coffee_bot():
print("Welcome to the cafe!")
size = get_size()
drink_type = get_drink_type()
print(drink_type)
print(size)
#drink
def get_size():
res = input("What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \n> ")
if res == "a":
return 'small'
elif res == 'b':
return 'medium'
elif res == 'c':
return 'large'
else:
print("I'm sorry, I did not understand your selection. Please enter the corresponding letter for your response.")
return get_size()
#drinkType
def get_drink_type():
res = input("What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n> ")
if res == "a":
return 'brewed coffee'
elif res == 'b':
return 'mocha'
elif res == 'c':
return order_latte()
else:
print("I'm sorry, I did not understand your selection. Please enter the corresponding letter for your response.")
return get_drink_type()
def order_latte():
res = "And what kind of milk for your latte? \n[a] 2% milk \n[b] Non-fat milk \n[c] Soy milk \n>"
if res == "a":
return '2% milk'
elif res == 'b':
return 'non-fat milk'
elif res == 'c':
return 'soy milk'
else:
print("I'm sorry, I did not understand your selection. Please enter the corresponding letter for your response.")
return order_latte()
# Call coffee_bot()!
coffee_bot()
when I am entering c in order_drink then a recursion is occuring
Please see the following FAQ for some guidance on how best to ask questions on the forums.
There’s something different about the order_latte()
function compared to some of your other functions. Can you spot why there’s no request for user input which would at least pause the infinite recursion?
2 Likes