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

Hrithik Sharma
Hrithik Sharma
6,090 Points

What's Wrong In My Code?

What is wrong in this it might be complicated but it works in vs code but in code challenge it show didn't get expected outcome

instances.py
listCombiner = []
listCombinerString = []
listAddNum = []
def combiner( list):
    for item in list:
        if (isinstance(item,str)):
            listCombinerString.extend(item)
        elif (isinstance(item, (int, float))):
            listAddNum.append(item)
        else:
            print("Only strings and number are allowed")
    listCombiner.append("".join(listCombinerString))
    listCombiner.append(str(sum(listAddNum)))
    print("".join(listCombiner))

combiner(["apple", 5.2, "dog", 8])

1 Answer

The code challenge is asking you to return the list not to print it. You should also remove the function call at the end for it to pass. Finally, I suggest not using reserved keywords as arguments such as list. Good luck.