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>Since response returned as value, it won't update the <code>response</code> variable inside <code>communicate</code> function. You need to update <code>response</code> with the value returned from the function:</p>

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

    AI_RESPONSE.set(response.get())           
    print (response.get())            
    print(AI_RESPONSE.get())
    root.update()
</code></pre>

python tkinter