title: Calling a variable through a button in Tkinter
body: <p>I'm new to Python and I've been reading some things about Tkinter and I find it really interesting; that said I have a problem with this code I have. I have this program that makes the computer pick a random number between 1 and 10 and you have to guess the number; yes, really simple; and since no new int is generated after a wrong attempt or a right attempt I want to make a button that generates a new random number when it had been clicked. I saw some solutions with 'Class' stuff but I'm not really familiar with it yet but if that's the best solution for my problem, well, I gotta see. </p>
  
  <pre><code>from Tkinter import *
  import random
  
  root = Tk()
  
  random_number = random.randint(1, 10)
  
  
  def retrieve_input(event):
      inp = float(number_space.get())
      if inp == random_number:
          print("You got it!")
      else:
          print("That's not the number.")
          print("The number was {}".format(random_number) + '.')
  
  
  
  number = Label(root, text="Guess a number between 1 and 10:")
  number.grid(row=0)
  number_space = Entry(root)
  number_space.grid(row=0, column=1)
  butt = Button(root, text="Generate a new random number")
  butt.grid(row=1, column=0)
  
  
  number_space.bind("&lt;Return&gt;", retrieve_input)
  
  
  
  
  root.mainloop()
  </code></pre>