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 trialJacob Truitt
1,646 PointsFunction Works, Doesn't Pass Challenge Task
This works in a test Workspace I have. I printed the called function and passed ("dog, 17, "cat", 8.2) as arguments, and receive the output of "dogcat25.2".
The error of 'Bummer: Didn't get the expected output' when I check the work for the challenge doesn't really give me much to go on.
Something I'm missing? Is there a way for me to see what arguments are being passed when checking this Challenge so I can more effectively debug?
def combiner(*args):
strings = ""
numbers = 0.0
for item in args:
if isinstance(item, str):
strings +=item
elif isinstance(item, (int, float)):
numbers += float(item)
return strings + str(numbers)
1 Answer
KRIS NIKOLAISEN
54,971 PointsThe challenge tells you a single list will be passed as an argument and gives you an example. If you want to test try:
print(combiner(["apple", 5.2, "dog", 8]))
and the result should be:
appledog13.2
Your code returns
0.0
Jacob Truitt
1,646 PointsJacob Truitt
1,646 PointsSo it does. I missed that. Thanks!