title: How to show the results of a program by entering something in input?
body: <p>So, I have a program, which I am finishing but I apparently ran into a problem. In the program I have to make that whenever I enter a 0 in the input, the program will stop and print the results. Here's the program before I continue saying anything else:</p>
  
  <pre><code>import collections
  students = collections.defaultdict(list)
  
  while True:
      student = input("Enter a name: ").replace(" ","")
      if student == "0":
          print ("A zero has been entered(0)")
          break
  
      if not student.isalpha():
              print ("You've entered an invalid name. Try again.")
              continue
  
      while True:
          grade = input("Enter a grade: ").replace(" ","")
          if grade == "0":
              print ("A zero has been entered(0)")
              break
  
          if not grade.isdigit():
              print ("You've entered an invalid name. Try again.")
              continue
  
          grade = int(grade)
          if 1 &lt;= grade &lt;= 10:
              students[student].append(grade)
              break
  
  for i, j in students.items():
      print ("NAME: ", i)
      print ("LIST OF GRADES: ", j)
      print ("AVERAGE: ", round(sum(j)/len(j),1))
  </code></pre>
  
  <p>I figured out a way how to make the program stop and post results after a 0 is entered in the <code>"Enter a name: "</code> part. This is what is printed out:</p>
  
  <pre><code>Enter a name: Stacy
  Enter a grade: 8
  Enter a name: 0
  A zero has been entered(0)
  NAME:  Stacy
  LIST OF GRADES:  [8]
  AVERAGE:  8.0
  </code></pre>
  
  <p>I need to do the same with the <code>"Enter a grade: "</code> part but if I try to make the program like it is now, this is what it prints out:</p>
  
  <pre><code>Enter a name: Stacy
  Enter a grade: 0
  A zero has been entered(0)
  Enter a name: 
  </code></pre>
  
  <p><strong>How do I make the program show results like it does when a 0 is entered in the name input?</strong></p>