title: How to return multiline string from a function?
body: <p>I have a function that returns a string of student names and maximum grades: Jade: 82. I also have a test function that has a test case that expects the returned value of the function to be a multiline string.</p>
  <pre><code>import sys
  
  grades = '''Jade,50,64,82,14
  Brenda,90,67,73,80
  Chris,75,75,75,75
  John,100,85,90,99'''
  
  
  def maximum(l: list):
      maxVal = 0
      for i in l:
          maxVal = max(maxVal, int(i))
      return maxVal
  
  
  def max_scores(grades):
      grades = grades.splitlines()
      finalGrades = []
      for i in grades:
          finalGrades.append(i.split(&quot;,&quot;))
      ans = &quot;&quot;
      for i in finalGrades:
          maxVal = maximum(i[1:])
          ans = ans + i[0] + &quot;: &quot; + str(maxVal)+&quot;\n&quot;
      return ans
  max_scores(grades)
  </code></pre>
  <p>Output (without including print)</p>
  <pre><code>'Jade: 82\nBrenda: 90\nChris: 75\nJohn: 100\n'
  </code></pre>
  <p>Output (with print in the return statement)</p>
  <pre><code>print(max_scores(grades))
  
  Jade: 82
  Brenda: 90
  Chris: 75
  John: 100
  </code></pre>
  <p>The test case</p>
  <pre><code>def test_max_scores():
      print(&quot;Testing get_max_scores()...&quot;, end=&quot;&quot;)
      grades = '''Jade,50,64,82,14
                      Brenda,90,67,73,80
                      Chris,75,75,75,75
                      John,100,85,90,99'''
  
      assert((max_scores(grades)) == '''Jade: 82
                                           Brenda: 90
                                           Chris: 75
                                           John: 100''')
      print(&quot;... done!&quot;)
  </code></pre>
  <p>I am unable to get the function to return the multiline string the test case is expecting.</p>