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

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