You can try doing this by creating some variable called something like "total". You can loop through the array add each value to total. At the end, divide by len(inputArray)
or just the size of array given.
For example, if we got this array:
a = [5,4,9]
you can use this code:
a = [5,4,9]
total = 0
for num in a: #for every item in array
total += a #total will equal 18 at end of loop
avg = total / len(a) # divide to get average.
#print or use variable avg. expected output: 6
or if you are wanting a way to convert string like "[0,3]" to an array, that is using string functions:
a = "[3,5]" #or a = any string given
a = a[1:]#delete first "["
a = a[:len(a)-1]# delete last "]"
a = a.split(",")#get all numbers separated by ","
#finally, turn all strings into numbers
for i in range(0, len(a) - 1):
a[i] = int(a[i])
And then use the average calculator in first code