title: Python: Returning array values from a function
body: <p>I'm trying to understand how to use functions properly. In this code, I want to return 2 arrays for pupil names and percentage scores. However I am unable to return the array variables from the first function.</p>
  <p>I've tried using different ways of defining the arrays (with and without brackets, both globally and locally)</p>
  <p>This is the relevant section of code for the program</p>
  <pre><code>#function to ask user to input name and score
  def GetInput():
      for counter in range(0,10):
          names[counter] = input(&quot;Please enter the student's name: &quot;)
          
          valid = False
          while valid == False:
              percentages[counter] = int(input(&quot;Please enter the student's score %: &quot;))
              if percentages[counter] &lt; 0 or percentages[counter] &gt; 100:
                  print(&quot;Please enter a valid % [0-100]&quot;)
              else:
                  valid = True
          return names, percentages
  
  name, mark = GetInput()
  </code></pre>
  <p>I'm expecting to be asked to enter the values for both arrays.</p>
  <p>I'm instead getting:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;H:/py/H/marks.py&quot;, line 35, in &lt;module&gt;
      name, mark = GetInput()
    File &quot;H:/py/H/marks.py&quot;, line 7, in GetInput
      names[counter] = input(&quot;Please enter the student's name: &quot;)
  NameError: global name 'names' is not defined
  </code></pre>