title: Cannot convert string to float in Python 3
body: <p>I'm trying to make a GPA calculator and I want the result as a <code>float</code>. However, I'm getting the following error: <code>cannot convert string to float:...</code></p>
  
  <p>I searched for similar solutions on this site but found one that didn't work either. It would be helpful if you could give me some hints.</p>
  
  <pre><code>from tkinter import *
  
  class gpa:
  
      def __init__(self, master):
  
          master.title("GPA CALCULATOR")
  
          self.result = StringVar()
          self.res = Entry(master, width = 60, textvariable = self.result)
          self.res.grid(row = 0, column = 0, columnspan = 6,padx = 3, pady = 6,  ipady = 6, sticky = "N E W S" )
  
          labels = '1st Semester GPA: ', '2nd Semester GPA: ','3rd Semester GPA: ','4th Semester GPA: ','5th Semester GPA: ','6th Semester GPA: ','7th Semester GPA: ','8th Semester GPA: ',
  
  
          row = 1
          col = 0
          i = 1
          for label in labels:
  
              self.l = Label(master, text = label)
              self.l.grid(row = row, column = col, sticky = E)
              row = row  + 1
  
  
  
  
  
  
          self.var1 = StringVar()
          self.var2 = StringVar()
          self.var3 = StringVar()
          self.var4 = StringVar()
          self.var5 = StringVar()
          self.var6 = StringVar()
          self.var7 = StringVar()
          self.var8 = StringVar()
  
  
          rows  = 1
          cols = 1
  
          for x in range(1, 9):
  
  
              self.ent = Entry(master, width = 30, textvariable = 'self.var'+str(x) )
              self.ent.grid(row = rows,pady = 6, column = cols, columnspan = 4, sticky = W)
              rows = rows + 1
  
              print('self.var' + str(x))
  
  
  
          self.button = Button(master, width = 20, text = "Calculate", command = self.calc())
          self.button.grid(row= 10, column = 1,columnspan = 5,   sticky = E)
  
  
      def calc(self):
  
              self.val1 = float(self.var1.get())
              self.val2 = float(self.var2.get())
              self.val3 = float(self.var3.get())
              self.val4 = float(self.var4.get())
              self.val5 = float(self.var5.get())
              self.val6 = float(self.var6.get())
              self.val7 = float(self.var7.get())
              self.val8 = float(self.var8.get())
  
              self.add = self.val1 + self.val2 + self.val3 + self.val4 + self.val5 + self.val6 + self.val7 + self.val8/8
              print(self.add)
  
              self.result.set(self.add)
  
  
  
  root = Tk()
  root.configure(padx =6, pady = 12)
  
  run  = gpa(root)
  
  root.mainloop()
  </code></pre>