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

Valeshan Naidoo
Valeshan Naidoo
27,008 Points

Task 2 of 2: task 1 no longer passing etc.

When I input the code for the 2nd challenge, it says that Task 1 is no longer passing. I'm not sure why. Also I'm not sure if I'm doing the 2nd challenge correctly anyway.

I'm thoroughly confused by the notes provided in the task and can't fully understand what is required but here's the code anyway:

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(list):
  sum = 0
  for items in list:
    sum = sum + items
  return(sum)

def summarize(list):
  return("The sum of" + summarize([1, 2, 3]) + "is" + add_list([1, 2, 3]))

3 Answers

Matthew Turner
Matthew Turner
2,564 Points

you'll want to use the format method for your string, and you'll want to actually call the add_list function. something like this: return "the sum of {} is {}.".format(list, add_list(list))

And don't forget to use the "list" variable.

The first thing I noticed, is on the two-parter questions, a lot of syntax errors and other exceptions will result in the "task 1 no longer passing" error message.

  • Make sure to use {} and .format() for text like this.

  • Make sure you use the 'list' variable in the right place.