Jonathan Garza4,475 Points
Challenge 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)
You 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: