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

James Perih
James Perih
4,184 Points

ValueError: zero length field name in format

What, exactly, does "string version of the list" really mean? My code works as expected in my own python3 interpreter... but doesn't work in this quiz? There must be inputs that I'm not understanding.

My code:

def add_list(list):
  result = 0

  for list_item in list:
    result = result + list_item

  return result

def summarize(list):
  string_version = "{}".format(list)
  sum_of_parts = add_list(list)

  return "The sum of {} is {}".format(string_version, sum_of_parts)
Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Just checked your code and it passes the first step of the CC. You're missing one tiny bit of punctuation before you can pass the second step.

2 Answers

Stone Preston
Stone Preston
42,016 Points

hmm I think that should work. your code looks correct. TTH has been having some issues with the challenges today so that could be it. I tried a few different ways of converting the list to a string such as:

string_version =  str(list)

and that didnt work either.

just used repli.it to run your code. I called the function and it output correctly.

below is what I used:

def add_list(list):
  result = 0

  for list_item in list:
    result = result + list_item

  return result

def summarize(list):
  string_version = "{}".format(list)
  sum_of_parts = add_list(list)

  return "The sum of {} is {}.".format(string_version, sum_of_parts)

print(summarize([1,2,3]))
Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yeah, your code looks fine. Seems we're having some CC issues today.