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 trialJonathan Garza
4,475 PointsChallenge Code Not Passing, but works in Workspaces
I'm having issues passing this challenge. I opened a workspace to help find errors. When I found a solution that worked, I copied into the challenge and was shocked to get the "Bummer" error message.
Here is the text from the challenge:
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.
def combiner(*args):
num = 0
string = ""
for item in args:
if isinstance(item,str) == True:
string += item
elif isinstance(item,(float,int)) == True:
num += item
string_num = str(num)
print(string + string_num)
1 Answer
KRIS NIKOLAISEN
54,971 PointsYou have two issues:
1) The challenge has asked you to return (not print) the result
2) The challenge will pass in a single list (one argument). To test in a workspace try adding the following after your function:
print(combiner(["apple", 5.2, "dog", 8]))
The result for your current code is:
0
Grant Murphy
10,072 PointsGrant Murphy
10,072 PointsI am having the same issue, my code returns the expected result given in the question but am receiving the "Not getting expected result" error. I am at a loss and getting really frustrated at this point.