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

Eldin Guzin
Eldin Guzin
6,010 Points

I am kind of stuck here

I know I have several problems here.I don't know how do I combine the strings together and it says that I have a TypeError... Explanation for this would be greatly appreciated

instances.py
def combiner(*args):
    lis1 = []
    lis2 = []

    for arg in args:
        if isinstance(arg, str):
            lis1.append(arg)
        elif isinstance(arg, int):
            lis2.append(arg)
    combined = lis1 + sum(lis2)
    return combined

1 Answer

Steven Parker
Steven Parker
229,952 Points

Here's a few hints:

  • the passed argument will be a list, you won't need the "splat" operator
  • as shown in the example, not all numbers will be integers
  • be sure to "join" the list of strings into a single string before combining with the numbers
  • convert the number sum to a string to avoid a TypeError
Eldin Guzin
Eldin Guzin
6,010 Points

Can you explain please what do you mean "splat" operator.

Steven Parker
Steven Parker
229,952 Points

"Splat" is just a nickname for the packing operator, or asterisk :point_right: *