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

I should be close

what is wrong here?

instances.py
def combiner(list)

strings = []
numbers = []

for item in list:
    if  isinstance(item, str):
        strings.append(item)
    elif isinstance (item, (float, int)):
        numbers.append(item)
    else:
        continue

return (str(strings)+str(sum(numbers)))

1 Answer

I am assuming you are trying to write a function. Your problem here is with indentation and the missing colon(:) after function definition. After defining the function you need to indent the code to be identify that it is part of/inside the function, and the same goes for if statement or loops. Anything indented(shifted to the right) means it is under or the first statement applies to it.

Usually indentation is achieved by Using Tab button

def combiner(list):
        strings = []
        numbers = []

        for item in list:
            if  isinstance(item, str):
                  strings.append(item)
            elif isinstance (item, (float, int)):
                   numbers.append(item)
            else:
                   continue

        return (str(strings)+str(sum(numbers)))

Please note that my indentation here is done manually by spacing not using tab.