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.


Luis Venegas
Luis Venegas
10,376 Points

Code checks out in Python IDLE, Code challenge won't accept it. Am I overlooking something?

The objective of the code is to combine an input list into a single string while also combining all numbers included in the list. I ran this code in a python3 shell and get the output "Appledog13.2" as the code challenge requires. (using the list ["Apple", 8, "dog, 5.2])

The code challenge won't accept it though, even while including further checks using isinstance.

Any help is very welcome! :)

def combiner(myList=[]):
    number = 0
    string = ""
    for val in myList:
        if isinstance(val, int) | isinstance(val, float) | isinstance(val, complex):
            number = number + val
        elif isinstance(val, str):
            string = string + val

    print("{}{}".format(string, number))

1 Answer

Your function should return the string. You are printing it.

Luis Venegas
Luis Venegas
10,376 Points

That makes sense, worked just fine! Thank you!