Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nancy Melucci
Courses Plus Student 36,159 PointsReturn outside of function
In the code below, the autograder ("Grok") tells me that the return is outside the function. This seems to happen no matter where I put the return statement. Any ideas?
import numpy as np
def calc_stats(list):
sum = 0
mean = 0
median = 0
for line in open('data.csv'):
row = []
for col in line.strip().split(','):
row.append(float(col))
for x in row:
mean = np.mean(row)
median = np.median(row)
return [mean, median]
1 Answer
Mark Sebeck
Treehouse Moderator 38,304 PointsYour first for statement needs indented so it’s inside the function. It should line up with median.
Nancy Melucci
Courses Plus Student 36,159 PointsNancy Melucci
Courses Plus Student 36,159 PointsThank you kindly!