Looping Coffee Chatbot

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
https://www.codecademy.com/paths/build-chatbots-with-python/tracks/python-3-data-structures-and-loops/modules/learn-python3-loops-chatbots/projects/coffee-chatbot-with-loops

I am having trouble with the Looping Coffee Chatbot project, i can’t figure out what is wrong with the code.
Every time I enter the code it says:

“Traceback (most recent call last):
File “script.py”, line 1, in
from utils import print_message, get_size, order_latte
File “/home/ccuser/workspace/coffee-chatbot-ii/utils.py”, line 31
def coffee_bot():
^
IndentationError: unindent does not match any outer indentation level”
Even thought there is nothing written on line 31.

I hope someone would be able to figure out this problem.

The error message says there’s an indentation issue. Did you double check your indentation throughout your code?

It’s difficult to tell since there’s no code to view. If you could please post your formatted code that would be helpful.

1 Like

Yes, of course.

from utils import print_message, get_size, order_latte

def coffee_bot():
print(‘Welcome to the cafe!’)

size = get_size()
drink_type = get_drink_type()

drink = ‘{} {}’.format(size, drink_type)
print(‘Alright, that's a {}!’.format(drink))

name = input('Can I get your name please? \n> ')
print(‘Thanks, {}! Your order will be ready shortly.’.format(name))

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_message()
return get_drink_type()

Define new functions here!

def print_message():
print(“I’m sorry, I did not understand your selection. Please enter the corresponding letter for your response.”)

coffee_bot()

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_message()
return get_size()

def order_latte():
res = input('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 ‘latte’
elif res == ‘b’:
return ‘non-fat latte’
elif res == ‘c’:
return ‘soy latte’
else:
print_message()
return order_latte()
return get_drink_type()

def coffee_bot():
print(‘Welcome to the cafe!’)

order_drink = ‘y’

while order_drink == ‘y’:
size = get_size()
drink_type = get_drink_type()

drink = '{} {}'.format(size, drink_type)
print('Alright, that\'s a {}!'.format(drink))  
order_drink = input('Would you like to order another drink? (y/n) \n> ') 

while True:
order_drink = input('Would you like to order another drink? (y/n) \n> ')
if order_drink in [‘y’, ‘n’]:
break
print(‘Okay, so I have:’)

for drink in drinks:
print(‘-’, drink)