title: Python - TypeError: 'NoneType' object is not iterable
body: <p>I am attempting to prevent the input of anything other than an integer for an average, but I keep receiving a Traceback for a TypeError. Below is my program, and the program output when attempting to input anything other than an int for an average:</p>
  
  <pre><code>grades_file = open('grades.txt', 'w')
  
  def get_averages():
      student = 1
      for i in range(3):
          name, average = get_name_average()
          student += 1
          grades_file = open('grades.txt', 'a')
          grades_file.write("Student Name: " + name + '\n' + "Student Average: " + str(average) + '\n\n')
          grades_file.close()
          print(("Added %s's average of %i to the file 'grades.txt. You are now entering information for student %i of 12.") % (name, average, student))
  def get_name_average():
      student_name = input("Please enter the student's name: ")
      try:
          student_average = int(input(("Please enter the average for %s: ") % student_name))
          verified_average = check_grade_input(student_average)
          return student_name, verified_average
      except ValueError:
          print("ERROR!! Please enter grade value as an integer!")
      except TypeError:
          print('Type error too!')
  
  def check_grade_input(average):
      legal_input = False
      while not legal_input:
          if (average &lt; 0):
              print("Nah bro,  invalid number...")
              average = int(input("Please enter another average that is above 0: "))
          elif (average &gt; 100):
              print("Nah bro,  invalid number...")
              average = int(input("Please enter another average that is below 100: "))
          else:
              return average
  
  def show_grades_file():
      grades_file = open('grades.txt', 'r')
      grade_contents = grades_file.read()
      grades_file.close()
      print("\nThe information you entered for into file 'grades.txt' is:\n\n" + grade_contents)
  
  def main():
      get_averages()
      show_grades_file()
  
  main()
  </code></pre>
  
  <p>Traceback and input:</p>
  
  <pre><code>Please enter the student's name: Aaron
  Please enter the average for Aaron: as
  ERROR!! Please enter grade value as an integer!
  Traceback (most recent call last):
    File "Documents/ProgrammingFundamentals/Lab6/aaron_blakey_Lab6b.py", line 52, in &lt;module&gt;
      main()
    File "Documents/ProgrammingFundamentals/Lab6/aaron_blakey_Lab6b.py", line 49, in main
      get_averages()
    File "Documents/ProgrammingFundamentals/Lab6/aaron_blakey_Lab6b.py", line 13, in get_averages
      name, average = get_name_average()
  TypeError: 'NoneType' object is not iterable
  </code></pre>