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 trialEldin Guzin
6,010 PointsI 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
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
231,236 PointsHere'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
6,010 PointsEldin Guzin
6,010 PointsCan you explain please what do you mean "splat" operator.
Steven Parker
231,236 PointsSteven Parker
231,236 Points"Splat" is just a nickname for the packing operator, or asterisk *