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

Now make a function named summarise that also takes a list.

Guys m stuck on this one,keeps on saying task 1 is no longer passing Now make a function named summarise that also takes a list.It should return the string "the sum of X is Y" replacing "X" with the string version of the list and "Y" with the total of the list

1 Answer

Brandon Mowat
Brandon Mowat
8,186 Points

Here is the solution. Make sure to read the question carefully and not to break your solution to any previous questions.

def add_list(list):
  out = 0
  for i in list:
    out += i
  return out

def summarize(list):
  sum = 0
  sum = add_list(list)
  return "The sum of {} is {}.".format(str(list), sum)

Thanx Brandon,it really worked out