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

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! :)

instances.py
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!