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

Keifer Joedicker
Keifer Joedicker
5,869 Points

Works through in private environment.

Its works fine in my own environment, but not in the Tree house one. Not sure where i'm wrong

instances.py
def combiner(x):
    a = []
    b = []

    for i in x:
        if isinstance(i, str):
            a.append(i)
        elif isinstance(i, int):
            b.append(i)
        else:
            continue

    return ''.join(a) + str(sum(b))

2 Answers

It looks like your code doesn't know what to do if a float is a part of the list. Try adding a "b.append(i)" under your else statement.

Good luck!

Keifer Joedicker
Keifer Joedicker
5,869 Points

I never thought about it that way, I overlooked floats! Thank you for you help it passed just fine.

Zach Waring
Zach Waring
6,895 Points
def combiner(this):
    string1 = ""
    string2 = ""
    numbersum = 0

    for item in this:
        if isinstance (item,str):
            string1 = string1 + item
        if isinstance(item, (int, float)):
            numbersum += item

    return string1 + str(numbersum)