Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import random
import tkinter as tk
root = tk.Tk()
userInput = tk.Entry(root)
userInput.pack()
greetings = ['hola', 'hello', 'hi', 'hey!', 'hey']
question = ['how are you?', 'how are you doing?', 'how are you', 'how are you doing']
responses = ['Okay', "I'm fine"]
huh = "I did not understand what you said"
def cb(event):
userText = userInput.get()
userText = userText.lower()
if userText in greetings:
botText = random.choice(greetings)
elif userText in question:
botText = random.choice(responses)
else:
botText = huh
output.config(text=botText)
userInput.bind("<Return>", cb)
output = tk.Label(root, text='')
output.pack()
tk.mainloop()