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

Yosef Berlin
Yosef Berlin
1,813 Points

I got the right output but, it's giving me an error

Hi, I ran this code in workspaces and I got the correct result. But I get a bummer message when I try the challenge. Please help

instances.py
def combiner(*args):
    seperator = ""
    num_list = []
    word_list = []
    for instance in args:
        if isinstance(instance, str):
            word_list.append(instance)
        elif isinstance(instance, (int,float)):
            num_list.append(instance)
    final_words = seperator.join(word_list)
    total_nums = sum(num_list)
    return final_words + str(total_nums)

1 Answer

The only thing you need to do is to remove the splat operator (asterisk).

The code challenge will give as input a list: ["apple", 5.2, "dog", 8]

At the moment, your code would only pass if the input were the arguments, comma-separated: "apple", 5.2, "dog", 8 which you then pack, effectively achieving the same result. Howeve the code challenge is not feeding you the args separately, and that's the reason why it fails.