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
Jeffrey Hacker
8,379 PointsPython Basics - functions.py challenge
Here's the challenge Make a function named add_list that takes a list. The function should then add all of the items in the list together and return the total. Assume the list contains only numbers. You'll probably want to use a for loop. You will not need to use input(). challenge clues are:
add_list([1, 2, 3]) should return 6
summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."
Note: both functions will only take one argument each.
I don't want to be given the solution, I want to figure it out, but I just don't understand what is being asked for on this challenge. I'm likely over thinking it, but am I supposed to start with a list containing "1, 2, 3" or is it append??? I'm assuming I need to have a function that makes the list and as I type in 1, 2, then 3 the 'summarize' function will break the loop and print the result Here's what I'm starting with
my_list = []
def add_list():
my_list.append(num)
def summarize():
Am I even on the right track??? thanks Jeff
1 Answer
Jeffrey Hacker
8,379 PointsI'd like to remove this post. I found some other discussions on the forum regarding this challenge. I think I'm just getting confused by the clues on the challenge that may not be a requirement to pass the quiz. thx, Jeff
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Jeffrey,
I think it'd be safe to delete this question since no one has provided an answer and you've figured it out. You should be able to delete your own question. If you can't figure it out let me know and I'll delete the question.