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

tomtrnka
tomtrnka
9,780 Points

Cant get past this challenge. No way to debug!

def combiner(mylist=[]):
    number_sum = 0
    string_line = ""
    for item in mylist:
        if isinstance(item, str):
            string_line += item
        elif:
            isinstance(item, (float, int)):
                number_sum += item
    return string_line + str(number_sum)

This was my first attempt, but no success ... keeps saying Bummer... I looked through "Get help" at one response and I changed my code to this:

def combiner(mylist=[]):
    numbers = []
    strings = []
    for item in mylist:
        if isinstance(item, str):
            strings.append(item)
        elif:
            isinstance(item, (float, int)):
                numbers.append(item)
    string_line = "".join(strings)
    numbers_sum = sum(numbers)
    return string_line + str(numbers_sum)    

But its still not working ... no idea where the problem is. It can be literally anywhere. I like Kenneth but I think he should really work on his exception descriptions cause from "Bummer: Try again!" I really cant tell wheres the problem. Last time I was doing different challenge and I had bad indentation at one line of code...and it just keeps saying Bummer... its really frustrating when you have no means how to deal with this.

1 Answer

Almost there. This is not correct syntax:

elif:
            isinstance(item, (float, int)):

it should read:

elif isinstance(item, (float, int)):

your code will then pass.