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.


Input ['apple','dog',1,2] output ['appledog3'] Not excepting from treehouse, please help

This is giving the correctout put in my ide but not for treehouse?

def combiner(args):
    my_list = ['apple','dog','banana',1,2,3.4]
    a = args
    string_list = [item for item in my_list if isinstance(item,str)]
    string_list.append(str(sum(item for item in my_list if isinstance(item,int) or isinstance(item,float))))
    strsum_list = ''.join(string_list)

1 Answer

Steven Parker
Steven Parker
220,925 Points

I see a few issues:

  • the code needs to work on the arguments passed in, it should not have any built-in data
  • the function needs to return the result
  • it will not need to "print" anything
  • you only need to define the function, you won't need to call it yourself

I deleted the items in my_list and replaced print with return as well as getting rid of my personal call of the function but its still not working. Not sure what now. https://ghostbin.com/paste/evh6n

Steven Parker
Steven Parker
220,925 Points

Interesting resource, "ghostbin"! I had not seen that before. I wonder who funds that?

But the args should not be put inside another list:

    my_list = []          # instead lf all this...
    a = args
    my_list = args        # you could just do this

You could also just use "args" directly instead of having "my_list" at all.

And at the end, when you return the string, don't enclose it in another list.

I dont know who funds "Ghostbin" but it is a great pastebin replacement for a quick paste that you wont be keeping.

Also ok thankyou that fixed it.

Steven Parker
Steven Parker
220,925 Points

Apparently "pastebin" is blocked by my network security filter, "ghostbin" might be soon.

But you can share formatted code right here as I did, using the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

That sucks that your network filters it I guess theres always vpns and tor. Thanks that is good to know.