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

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!

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