title: Assign user input to a variable in Python
body: <p>I am having some problem when trying to get the input text and assign them to variable in Python. Here are my code:</p>
  
  <pre><code>#!/usr/bin/python3
  
  from tkinter import *
  fields = 'Last Name', 'First Name', 'Job', 'Country'
  
  def fetch(entries):
     for entry in entries:
        field = entry[0]
        text  = entry[1].get()
        print('%s: "%s"' % (field, text)) 
  
  def makeform(root, fields):
     entries = []
     for field in fields:
        row = Frame(root)
        lab = Label(row, width=15, text=field, anchor='w')
        ent = Entry(row)
        row.pack(side=TOP, fill=X, padx=5, pady=5)
        lab.pack(side=LEFT)
        ent.pack(side=RIGHT, expand=YES, fill=X)
        entries.append((field, ent))
     return entries
  
  if __name__ == '__main__':
     root = Tk()
     ents = makeform(root, fields)
     root.bind('&lt;Return&gt;', (lambda event, e=ents: fetch(e)))   
     b1 = Button(root, text='Show',
            command=(lambda e=ents: fetch(e)))
     b1.pack(side=LEFT, padx=5, pady=5)
     b2 = Button(root, text='Quit', command=root.quit)
     b2.pack(side=LEFT, padx=5, pady=5)
     root.mainloop()
  </code></pre>
  
  <p>When I ran this, it managed to print out first and last name, job and country respectively. But I am using a loop to loop through the entries. I was thinking if it is possible to get each of them and assign to a variable because I need the values to do some validation and SQL statement.</p>
  
  <p>Thanks in advance.</p>