I am using an array 'array_studentDetails'. This array will be used by other functions after it is initialized.
Should I make it a global array as I have done in this example
OR
should i return the array to the calling function and pass it on to the other function that require them as a parameter?
# initialize global variables
array_studentDetails = []
def populate_array(allRecords):
# validate parameters
# TODO
# initilize local variables
numberOfRecords = 0
# initialize array
for record in allRecords:
numberOfRecords += 1
#Format : e = ['1','name']
oneArrayElement = [record[0], record[1]]
array_studentDetails.append(oneArrayElement)
return numberOfRecords
function test
-------------
allRecords = [(1,'rupesh'), (2, 'upesh')]
populate_array(allRecords)
2
array_studentDetails[0][0]
1
array_studentDetails[0][1]
'rupesh'