title: Calling functions and passing arrays in python
body: <p>I'm new here and new to python. i'm usually used to C, javascript and php coding.</p>
  
  <p>I'm trying to call one function to perform an SQL Query, and then add the data to some arrays.</p>
  
  <p>Then i'd like to pass multiple arrays onto another function to print them for example, and be able to access any part of that array at will.</p>
  
  <p>so to sum up.......I have two functions, One gathers information from an sql query, and stores the columns and rows into a few arrays. The next function is supposed to grap those passed arrays from the previous function and print them (for now). im just trying to get the arrays into the next function so I can do what i need with them later. passing them through is the milestone that im having trouble i'm just not too sure how to call the functions, and correctly code them so that the first function passes the arrays onto the next function for printing or doing what ever is needed with the arrays</p>
  
  <p>Not sure if i'm doing things correctly here, just wondering if someone could point me int he right direction.</p>
  
  <p>Thanks</p>
  
  <pre><code>import mysql.connector
  
  
  def grabdata():
  
      mydb = mysql.connector.connect(
        host="xxxxxxxxxx",
        user="xxxxxxx",
        passwd="xxxxxxx",
        database="vmware"
      )
  
      print(mydb)
  
      mycursor = mydb.cursor()
  
      mycursor.execute("select UserID, VMName, VMTemplate FROM VM WHERE CommissionStatus='commissioned';")
  
  
      ReturnedUser_id = []
      ReturnedVMName = []
      ReturnedVMTemplate = []
  
      for (User_id, VMName, VMTemplate) in mycursor:
          ReturnedUser_id.append(User_id)
          ReturnedVMName.append(VMName)
          ReturnedVMTemplate.append(VMTemplate)
  
      return(ReturnedUser_id,ReturnedVMName)
  
  
  
  
  
  
  def printdata(ReturnedUser_id,ReturnedVMName):
  
  
  
  
      testarray = ReturnedUser_id
      testarray2 = ReturnedVMName
  
      print(testarray[2])
      print(testarray2[2])
  
      return()
  </code></pre>