Python Object-Oriented Python Inheritance Instances

Luis Venegas
Luis Venegas
10,376 Points

Code checks out in Python IDLE, Code challenge won't accept it. Am I overlooking something?

The objective of the code is to combine an input list into a single string while also combining all numbers included in the list. I ran this code in a python3 shell and get the output "Appledog13.2" as the code challenge requires. (using the list ["Apple", 8, "dog, 5.2])

The code challenge won't accept it though, even while including further checks using isinstance.

Any help is very welcome! :)

instances.py
def combiner(myList=[]):
    number = 0
    string = ""
    for val in myList:
        if isinstance(val, int) | isinstance(val, float) | isinstance(val, complex):
            number = number + val
        elif isinstance(val, str):
            string = string + val

    print("{}{}".format(string, number))

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,479 Points

Your function should return the string. You are printing it.

Luis Venegas
Luis Venegas
10,376 Points

That makes sense, worked just fine! Thank you!