https://app.dataquest.io/m/315/functions%3A-fundamentals/11/combining-functions
Your Code: Enclose your code in 3 backticks like this
to format properly: your code
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
def extract(data_set, index):
column = []
for row in data_set[1:]:
value = row[index]
column.append(value)
return column
def find_sum(a_list):
a_sum = 0
for element in a_list:
a_sum += float(element)
return a_sum
def find_length(a_list):
length = 0
for element in a_list:
length += 1
return length
def mean(data_set, index):
column=extract(data_set, index)
return find_sum(column) / find_length(column)
avg_price = mean(apps_data,4)
What I expected to happen:
I am not really sure. I was stuck, and the hints did not help so I broke down and look at the answer.
Where I am confused is that there is a list named column, but in the mean functionhas variable named column, but that is the name of the list. I renamed the items in the return row and the lesson still let me pass.
Would we want to do something like this in practice? Why are these two items named the same?
If I wanted to print(column) it did not seem to print anything.
Thank you.