Why isn't my function returning anything?
<p>I am attempting to make a rudimentary chatbot using python and tkinter, and have ran into an issue. I have excluded tkinter code for simplicity. The entire code is visible at the bottom.</p>

<pre><code> def communicate():
        sent.set(HUMAN_ENTRY.get())
        bottalk(response)

        AI_RESPONSE.set(response.get())           
        print (response.get())            
        print(AI_RESPONSE.get())
        root.update()

 def bottalk(response):
        if sent == 'hello': 
            response = 'hello recieved'
        else:
           response = 'hello not recieved'
        return response

 AI_RESPONSE = 'hellgeto'
 header.pack()
 sent = StringVar()
 response = StringVar()
 AI_RESPONSE = StringVar()
</code></pre>

<p>An input is made into a entry box, and is sent to the communicate function, which sends the input to the bottalk function, which should set response to either "hello received" or "hello not received", and update a label on the GUI. However, when I do this, the label does not change, and the console outputs what seems to be two blank lines. <em>Why is my function not setting response to either "hello received" or "hello not received", and if it is, why is it not printing this or updating the GUI?</em></p>

<p><strong>Print(AI_RESPONSE) resulting in Py-Var2 was to show that 2 blank lines out outputted. My question does not concern that line.</strong></p>

<pre><code>from tkinter import *
import random


class App:
    def __init__(self, master):

    def close():
        quit()

    def communicate():
        sent.set(HUMAN_ENTRY.get())
        bottalk(response)

        AI_RESPONSE.set(response.get())           
        print (response.get())            
        print(AI_RESPONSE.get())
        print(AI_RESPONSE)
        root.update()

    def bottalk(response):
        if sent == 'hello': 
            response = 'hello recieved'
        else:
            response = 'hello not recieved'
        return response

    AI_RESPONSE = 'hellgeto'
    root.title=('GoBot')
    frame = Frame(master)
    frame.pack()
    self.button = Button(frame,text='Send', command=communicate)
    self.button.pack(side=LEFT)
    self.button2 = Button(frame,text='Quit', command=close)
    self.button2.pack(side=RIGHT)
    header = Label(frame, text='GoBot', fg= 'blue', font = 'Times')
    header.pack()
    sent = StringVar()
    response = StringVar()
    AI_RESPONSE = StringVar()
    HUMAN_ENTRY = Entry(master, bd = 5)
    HUMAN_ENTRY.pack(side=RIGHT)
    responselabel = Label(frame, textvariable=AI_RESPONSE, fg = 'purple', font = 'ComicSans', anchor ='s')
    responselabel.pack()




root = Tk()
app = App(root)      
root.mainloop()
</code></pre>

<p><a href="http://i.stack.imgur.com/GSOXj.png" rel="nofollow"><img src="http://i.stack.imgur.com/GSOXj.png" alt="The Console"></a></p>

<p><code>response</code> is <code>StringVar</code> so you have to use <code>.set(text)</code> instead of <code>=</code> </p>

<pre><code>def bottalk(response):
    if sent == 'hello': 
        response.set('hello recieved')
    else:
        response.set('hello not recieved')
</code></pre>

<p>And now you don't have to return value, and don't need to use <code>global</code>. And you see text in label and console.</p>

python tkinter