Python Object-Oriented Python Inheritance Instances

Grant Murphy
Grant Murphy
10,072 Points

My code outputs the expected output in the work-space but receiving "Did not get expected output". Help!

Title says it all, my function works as asked but not passing the test. So I do not know if I am simply not reading the question right or maybe I am not returning the information the correct way. Again I am not sure. Any help would be greatly appreciated, thank you!

instances.py
def combiner(*args):
    num = []
    words = []
    final = ""
    for item in args:
        if isinstance(item, (int, float)):
            num.append()
        else:
            words.append(item)
    lsum = sum(num)        
    words.append(lsum)
    listToStr = "".join([str(elem) for elem in words]) 
    return listToStr

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,553 Points

You have two issues

1) You are missing an argument so you aren't appending anything here:

num.append()

2) In using *args you are accepting a variable number of arguments. The challenge specifies that the function will take a single list as an argument. Hint: Don't use *args.

Try this in a workspace to test

def combiner(*args):
    num = []
    words = []
    final = ""
    for item in args:
        print(item)

        if isinstance(item, (int, float)):
            num.append(item)
        else:
            words.append(item)
    lsum = sum(num)        
    words.append(lsum)
    listToStr = "".join([str(elem) for elem in words]) 
    return listToStr



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