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

functions challenge task 2

Well, I'm back. Sorry about that!

I didn't think I'd have this much trouble, but they are challenges after all. I get the error 'Can't convert to str implicitly' or I think it actually says it cant convert the list to str implicitly. I thought by splitting it, it converted it to a string. Though I think I remember now that it doesn't work on integers? I say that because in one of the quizzes was that '+'.split([1, 2, 3]) would not work.

Anyway, any help is largely appreciated!

EDIT: I figured it out!

functions.py
def add_list(list):

    total = 0

    for i in list:
        total += i

    return total

def summarize(list2):
  X = ' '.split(list2)
  Y = add_list(list2)

  print("The sum of {} is {}".format(X, Y))

1 Answer

Gunhoo Yoon
Gunhoo Yoon
5,027 Points

Split does not operate on string. The syntax in this case would be list.split('separator') you are probably confused with join().

Yeah I did some more research and finally got the answer. I did confuse those 2 though :L