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

isinstance() method

Not sure if it is a syntax error or my logic, I keep getting "try again"

instances.py
def combiner(["apple", 5.2, "dog", 8]):
    a = ""
    counter=0
    for x in combiner:
        if isinstance(x,str):
            a.append(x)
    else:
        if isinstance(counter,(int,float)):
            counter.append(x)
    y = str(counter) + a
    return y    

1 Answer

Tom Watson
Tom Watson
9,987 Points

You're passing the list when you define the function, rather than when it's called - try replacing:

def combiner(["apple", 5.2, "dog", 8]):

with:

def combiner(my_list):

to see if that fixes your issue.

Thanks Tom, I just fixed that , but it still given me errors