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

When I click check work, I get a message saying that I didn't get the expected result. What am I doing wrong?

Already tried this code in the python workspace, and it worked.

instances.py
def combiner(*list):
    number = 0
    string = []
    for item in list:
        if isinstance(item, (int, float)):
            number = number + item
        elif isinstance(item, str):
            string.append(item)

    result = "{}{}".format("".join(string),number)
    return result

2 Answers

The checker will pass in a single list as an argument. Try the following with your function in a workspace:

print(combiner(["apple", 5.2, "dog", 8])) 

Your code returns 0.

Thanks, just checked my code, and the problem was that I was assuming that the input would be a multiple arguments instead of just one list.

I just got rid of the asterisk in the combiner argument, and that fixed the code.

Thanks for your help