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 don't understand why this wont pass.

This took me three days to get this to work, but still not passing on the actually test, and i don't know why. i've tried different inputs, and i'm always getting back string seperated with nothing, then sum of my number list.....please help.

instances.py
def combiner(items) :
    string = []    
    number = []
    s = ""
    for item in items:
        if isinstance(item, str) == True:
            string.append(item)
        elif isinstance(item, int) == True:
            number.append(item)  
    string = s.join(string)
    combined = f"{string}{sum(number)}"
    return combined

2 Answers

You also need to consider floats

def combiner(items) : string = []
number = [] s = "" for item in items: if isinstance(item, str) == True: string.append(item) elif isinstance(item, (int, float)) == True: number.append(item)
string = s.join(string) combined = f"{string}{sum(number)}" return combined

fixed it about 2 seconds ago. was trying to update. lol

Thanks, that answer was spot on thought. Ended up testing with a float. notice it was getting out throw out cause of elif. researched how to add to arg in to isinstance, then bing bang boom!!

This site help my code too for whoever else this my help.
https://www.programiz.com/python-programming/methods/built-in/isinstance