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 trialKeifer Joedicker
5,869 PointsWorks through in private environment.
Its works fine in my own environment, but not in the Tree house one. Not sure where i'm wrong
def combiner(x):
a = []
b = []
for i in x:
if isinstance(i, str):
a.append(i)
elif isinstance(i, int):
b.append(i)
else:
continue
return ''.join(a) + str(sum(b))
2 Answers
yolo4ever
3,787 PointsIt looks like your code doesn't know what to do if a float is a part of the list. Try adding a "b.append(i)" under your else statement.
Good luck!
Zach Waring
6,895 Pointsdef combiner(this):
string1 = ""
string2 = ""
numbersum = 0
for item in this:
if isinstance (item,str):
string1 = string1 + item
if isinstance(item, (int, float)):
numbersum += item
return string1 + str(numbersum)
Keifer Joedicker
5,869 PointsKeifer Joedicker
5,869 PointsI never thought about it that way, I overlooked floats! Thank you for you help it passed just fine.