title: Why is 'NoneType' object not iterable in HackerRank, but not PyCharm?
body: <p>Using Python 3.x, I'm trying to round up students grades given a teacher's weird way of grading. Basically, if the student grade is below 38, do nothing. If the difference between the grade and the next multiple of 5 is less than 3, round the grade up to the next multiple of 5. Otherwise, don't change the grade. Here is the code I've used in both PyCharm and HackerRank's web-based IDE:</p>
  
  <pre><code>grades = [37, 39, 52, 83, 91]
  
  def gradingStudents(grades):
      for i in range(len(grades)):
          grade = grades[i]
          if grade &gt; 38:
              for j in range(4):
                 next_val = grade + j
                 if ((next_val-grade) &lt; 3) and (next_val%5 == 0):
                     grade = next_val
          print(grade)
  
  gradingStudents(grades)
  </code></pre>
  
  <p>The output in PyCharm is correct: </p>
  
  <pre><code>37
  40
  52
  85
  91
  </code></pre>
  
  <p>For comparison, here is the code from from the web-based IDE in HackerRank (<a href="https://www.hackerrank.com/" rel="nofollow noreferrer">https://www.hackerrank.com/</a>): </p>
  
  <pre><code>#!/bin/python3
  import os
  import sys
  
  #
  # Complete the gradingStudents function below.
  #
  def gradingStudents(grades):
      for i in range(len(grades)):
          grade = grades[i]
          if grade &gt; 38:
              for j in range(4):
                 next_val = grade + j
                 if ((next_val-grade) &lt; 3) and (next_val%5 == 0):
                     grade = next_val
          print(grade)
  
  if __name__ == '__main__':
      f = open(os.environ['OUTPUT_PATH'], 'w')
  
      n = int(input())
  
      grades = []
  
      for _ in range(n):
          grades_item = int(input())
          grades.append(grades_item)
  
      result = gradingStudents(grades)
  
      f.write('\n'.join(map(str, result))) #&lt;-- This is line 32 from error!
      f.write('\n')
  
      f.close()
  </code></pre>
  
  <p>This throws the following error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "solution.py", line 32, in &lt;module&gt;
  f.write('\n'.join(map(str, result)))
  TypeError: 'NoneType' object is not iterable
  </code></pre>