import string # feel free to give any chatbot name you like chatbot_name = "Fitri" + "Bot" # sentinel loop: a loop that keeps going until reaching the end signal given by the user while(True): # simple string preprocessing for given user message user_message = input("You: ").lower().strip(string.punctuation+string.whitespace) # the response by the chatbot starts by printing its name print(chatbot_name + ":", end=' ') # finish conversation by saying quit (or selesai) if user_message == "quit" or user_message == "selesai": print("Sampai ketemu lagi 👋") break # conditionals for conversation if user_message == "halo": print("Halo juga 😊", end='') elif user_message == "apa kabar": print("Baik nih 👌 kamu gimana?", end='') elif "cuaca cerah" in user_message: # check string containment print("Iyaa, secerah hatiku ketika memandang wajahmu 😳", end='') # mendung (= cloudy) flow elif "mendung" in user_message: print("Hati atau cuaca?", end='') elif user_message == "hati": print("*sending virtual hugs 🤗*", end='') elif user_message == "cuaca": print("Cuma cuaca kan, bukan hati 😝", end='') elif user_message == "makasih" or user_message == "thanks": print("Masama 👍", end='') # if none matches (aka the chatbot gets confused) else: print("Eh2, gimana? 😵", end='') print()