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!
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
Leo Marco Corpuz18,975 Points
Here's my updated code. Im getting an error saying on third line item, str expected but float was found.
def combiner(oldList): newList= number=0 for item in oldList: if isinstance(item,str): newList.append(item) elif isinstance(item,(float,int)): number+=item newList.append(number) return "".join(newList)
Louise St. Germain19,424 Points
The issue is that you are trying to use join on a float, which is the number variable you've tacked onto the end of your newList.
When join tries to join a string with a float, it throws an error. To avoid this, you'll need to convert 'number' to a str before adding it to the newList, like this:
# Remove this... newList.append(number) # And replace with... newList.append(str(number))
Alternatively, you could delete that newList.append(number) line altogether, and only at the very end, concatenate a string version of your number to the string list, like this:
# Remove this line entirely: # newList.append(number) # and change the last line to: return "".join(newList) + str(number)
Either way should fix the problem. Good luck!