Coffee Chatbot Project (Build Chatbots with Python)

Hello everyone,

Here is my effort for my first Coffee Chatbot:

For some reason the script is working on the skill path’s interpreter, but on the one below! But you can still see the code, so, hopefully, it is still helpful:

# Define your functions def coffee_bot(): print("Welcome to the cafe!") name = input("Can I get your name please? ") size = get_size() drink_type = get_drink_type() print("Alright, that's a {} {}!".format(size, drink_type)) print("Thanks {}! Your drink will be ready shortly. /n".format(name)) extra_order() def get_size(): res = input("What size drink can I get for you? \n[a] Small \n[b] Medium \n[c] Large \nPlease enter the corresponding letter for your response. \n") if res == "a": return "small" elif res == "b": return "medium" elif res == "c": return "large" else: print_message() return get_size() def print_message(): print("I'm sorry, I did not understand your selection. Please enter the corresponding letter for your response.") def get_drink_type(): res = input("What type of drink would you like? \n[a] Brewed Coffee \n[b] Mocha \n[c] Latte \n Please enter the corresponding letter for your response. \n") if res == 'a': return "Brewed" elif res == 'b': return "Mocha" elif res == 'c': return order_latte() else: print_message() return get_drink_type() 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 Please enter the corresponding letter for your response. \n") if res == "a": return "Latte with 2% milk" elif res == "b": return "Latte with Non-fat milk" elif res == "c": return "Latte with Soy milk" else: print_message() return order_latte() def extra_order(): res = input("Do you need another cup of coffee? \n[a] Yes \n[b] No \nPlease enter the corresponding letter for your response.\n") if res == "a": return get_size(), get_drink_type(), extra_order() elif res == "b": print("That's great, I wish you a great day!") else: print_message() return extra_order() # Call coffee_bot()! coffee_bot()

Looks great, well done! :clap:
The only (very minor) thing I would point out is that on line 54, you are missing the parentheses from the function call so it’s not actually calling print_message(), just referencing it:

  else:
    print_message
    return order_latte()

In regards to the EOF error it throws in the above codebyte, that’s not actually an issue with your code at all so don’t worry about it! It’s just that some Codecademy environments (such as codebytes on the forums and most exercise terminals) aren’t able to receive user input via the terminal and it throws an EOF error if you try.

Well done! :tada:

Hello @notlyall ,

Thank you for your feedback, it is much appreciated.

Regarding the missing parentheses, that’s was a good catch, thanks for pointing that out! I will edit it now.

Also, thank you for letting me know that input() does not work on forums!

Have a great day,
Charalampos.

1 Like