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 trialMichele Cynowicz
1,988 PointsI am writing a for loop here and I don't see why it isn't evaluating correctly. Where can I get help?
The lesson preceding this challenge doesn't cover all the challenge content. I am not getting enough feedback from the work-checker to figure out where I've gone wrong with this. Is there someone that can help me?
3 Answers
Kenneth Love
Treehouse Guest TeacherThe challenge requires you to loop over the items in a list. We covered looping over a list in the Shopping List Project video. If you don't want to watch it again, it's the syntax:
>>> my_list = [4, 8, 10]
>>> for num in my_list:
... print(num)
4
8
10
You'll also need to give yourself a starting point for adding all of these numbers together. I'd suggest a variable that's set to 0.
Michele Cynowicz
1,988 PointsI wish this interface had allowed me to copy & paste the code or the task from the challenge. I didn't realize the question was being posted to a forum, I thought it would be answered by the instructor.
Michele Cynowicz
1,988 PointsThanks. I see what I was missing now was to pre-define the list before writing the function.
Kenneth Love
Treehouse Guest TeacherYou don't have to define the list for the CC to pass. I'll give your function a list as an argument when it gets tested. But if you're writing the code somewhere else first, then, yes, you'll need a list.
Michele Cynowicz
1,988 Pointsthat's what I originally thought, Kenneth Love ... that I could write the function without pre-defining the list itself. Which is why I couldn't figure out what I had done wrong, since the function was indeed correct. Going back and adding the list = [1,2,3] before the function definition was the proper fix to pass the code challenge.
Cody Coats
7,469 PointsCody Coats
7,469 PointsIf you post your code, I can take a look and help out.