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 trialRicardo Franco
Data Analysis Techdegree Student 16,258 Pointsinstances coding challenge
I am at a loss...am I supposed to return first a concatenation of the string list elements, followed by the addition of the numerical elements and then combine it into a single string. That feels like a lot of steps and I get the feeling this challenge was not meant of to be that deep. Please assist. Thanks in advance.
def combiner(list):
list = isinstance(["apple", 5.2, "dog", 8], (str, float))
return list
1 Answer
Steven Parker
231,269 PointsThere are several steps, but if you break it down it's not so bad:
- create variables for collecting strings and for summing numbers
- first, write a loop that will iterate through the list one item at a time
- test each item using "isinstance" to determine what it is
- if it's a string, concatenate it to the end of the collection string
- if it's a number, add it to the sum
- after the loop is over, convert the sum to a string and concatenate on the string collection
- finally return the big string
Also, check the syntax for calling a method (like "isinstance").