Python Object-Oriented Python Inheritance Instances

Mario Aro
Mario Aro
7,476 Points

When I click check work, I get a message saying that I didn't get the expected result. What am I doing wrong?

Already tried this code in the python workspace, and it worked.

instances.py
def combiner(*list):
    number = 0
    string = []
    for item in list:
        if isinstance(item, (int, float)):
            number = number + item
        elif isinstance(item, str):
            string.append(item)

    result = "{}{}".format("".join(string),number)
    return result

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,693 Points

The checker will pass in a single list as an argument. Try the following with your function in a workspace:

print(combiner(["apple", 5.2, "dog", 8])) 

Your code returns 0.

Mario Aro
Mario Aro
7,476 Points

Thanks, just checked my code, and the problem was that I was assuming that the input would be a multiple arguments instead of just one list.

I just got rid of the asterisk in the combiner argument, and that fixed the code.

Thanks for your help