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 trialJulianne Soifer
716 PointsNameError on my function. I can't understand how this is "not "defined". Haven't I just defined it as my function?
I have been stuck on the second part of this for days! How am I to further define my summarize function? It took my add_list function ...
Julianne Soifer
716 PointsI'm just a mess, I guess. I was sure I had the attach code box checked. I don't know how to add it now.
Chris Freeman
Treehouse Moderator 68,441 PointsYou can cut-and-paste it into a comment
Julianne Soifer
716 PointsThat's what I tried to do! I cannot believe I can't even cut and paste right now!!! Thanks for your patience. I will figure out what's going on.
Chris Freeman
Treehouse Moderator 68,441 PointsWeird, I saw your code in a comment, then it disappeared. Here's what I captured:
num_list = []
def add_list(num_list):
for item in num_list:
total = sum(num_list)
return total
def summarize(num_list):
return "The sum of {} is {}.".format( str(num_list), sum(num_list))
[MOD: added ```python markdown formatting -cf]
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsWhen I run your code, it passes as written in the challenge.
Julianne Soifer
716 PointsThat is weird. You got what I've tried. It seems logical to me. I wonder why it isn't passing the challenge. Thank you so much for your time! :)
Chris Freeman
Treehouse Moderator 68,441 PointsSo it's still not passing or you're wondering why it didn't but now does?
There have been some glitches in the challenge grading, where the correct code failed, but passes a short time later.
Julianne Soifer
716 PointsStill not passing challenge. The first part passes and the I get "NameError: "summarize" not defined for the second
Chris Freeman
Treehouse Moderator 68,441 Pointscheck the indentation. the def add_list
and def summarize
must both start in column 1. Also try adding a blank line between the functions for clarity (shouldn't matter syntactically).
Julianne Soifer
716 PointsThank you thank you thank you!!! It worked when I adjusted the indentation!
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsCan you post your code?
From the docs