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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Rutendo Chaurura](https://uploads.teamtreehouse.com/production/profile-photos/10753488/micro___263_78_280_6555__20171116_172318.jpg)
Rutendo Chaurura
6,809 Pointshelp me on this task
Alright, here's a fun task! Create a function named combiner that takes a single argument, which will be a list made up of strings and numbers. Return a single string that is a combination of all of the strings in the list and then the sum of all of the numbers. For example, with the input ["apple", 5.2, "dog", 8], combiner would return "appledog13.2". Be sure to use isinstance to solve this as I might try to trick you.
here is my code
def combiner(mylist): number = 0 string = ""
for item in mylist:
if isinstance(item, str):
string += item
elif isinstance(item, (int, float)):
number += item
return string + str(number)
def combiner(mylist):
number = 0
string = ""
for item in mylist:
if isinstance(item, str):
string += item
elif isinstance(item, (int, float)):
number += item
return string + str(number)
1 Answer
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,423 PointsYou are very close! The return
is indented too far. This causes the for
loop to return after the first iteration.