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 trialAnnie Scott
27,613 Pointsbummer check preview for details , I have space in between , but it is still not working what am i doing worn
need help answer is almost right
def average(num_list):
""" Return the sum of a list of numbers
>>> average([1, 2])
1.5
"""
return sum(num_list)
3 Answers
Chris Bennett
7,499 PointsIt's asking for an average. You're half way there.
You'll need to use the len() function on num_list to return the length of the list.
Then divide sum(num_list) by len(num_list).
def average(num_list):
""" Return the sum of a list of numbers
>>> average([1, 2])
1.5
"""
return sum(num_list) / len(num_list)
Annie Scott
27,613 PointsNote after numbers hit enter and after 1.5 hit enter must have a line of space
def average(num_list):
""" Return the sum of a list of numbers
>>> average([1, 2])
1.5
"""
return sum(num_list) / len(num_list)
Chris Bennett
7,499 PointsThat's weird but I'm glad you got it working, Cheers!
Annie Scott
27,613 PointsAnnie Scott
27,613 Pointsthank you so much that worked, NOTE: had to delete all empty space lines and then add the spacing in the lines in between average and after the 1.5 and it finally worked.