Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Valeshan Naidoo
Valeshan Naidoo
27,007 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:

# 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

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.