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

Python Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

mahesh gurbaxani
mahesh gurbaxani
1,420 Points

please give solution to this problem

please give solution. Thanks

functions.py
# 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.
def add_list()=add_num(num)
    print("what number should i enter")
    print("done to stop")
  continue
    if num=done
  break
   else
      for item in add_list

2 Answers

Jan Van Raemdonck
Jan Van Raemdonck
22,961 Points

Try to write the add_list function first, and try not to overthink it. consider using a variable to be able to store the value of the sum as it increases in your for loop.

The summarize function is really easy, just use the add_list function you just wrote to solve that one.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Please stop asking people to give you the solutions. The code challenges are meant to be challenging, it's in the name.

On the opposite side of that, please stop giving out full solutions. Learning requires effort and giving a full answer deprives someone of that experience and achievement.

Jan Van Raemdonck
Jan Van Raemdonck
22,961 Points

You're totally right Kenneth, I'm sorry for my shortsightedness :s I know it's a little late now, but i'll alter my answer so it doesn't just give it away for next visitors to this question...