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 trialBlessing Nyamayedenga
6,283 Pointsinstances challenge
hey guys im not sure what im doing wrong here ,please help
def combiner(str_num):
mixed_list = ["mom", "eldrine", "kiki",8, 5, 8, 5, 2, 3]
str_num = []
nums = 0
strings = []
for item in mixed_list:
if isinstance(item, str):
strings.join(item)
else:
nums += item
str_nums = strings.join(str,nums)
return str_num
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou are very close. Here are the items to fix:
- the
for item
loop should loop over thestr_num
argument, not the static test valuemixed_list
- use
strings.append
instead ofstrings.join
. Alist
object has nojoin
method - use
"".join(strings)
to get the strings into one string - use
str(nums)
to get the numbers into a string - You can use + to combine these in the return statement.
- the
str_nums
assignment should be outside of thefor
loop
Post back if you need more help. Good luck!!
Blessing Nyamayedenga
6,283 Pointshere is what I did but im still getting a bummer saying didn't get expected result
def combiner(str_num):
str_num = ["mom", "eldrine", "kiki",8, 5, 8, 5, 2, 3]
nums = []
strings = []
for item in str_num:
if isinstance(item, str):
strings.append(item)
elif isinstance(item,(int,float)):
nums.append(item)
nums = sum(nums)
strings = "".join(strings)
return strings + str(nums)
Blessing Nyamayedenga
6,283 PointsBlessing Nyamayedenga
6,283 PointsThanks Chris I finally got it