Python Object-Oriented Python Inheritance Instances

I get this Python unsubscriptable error how do i solve it

def combiner(list_of_datas): sum = 0 words = [] for item in list_of_datas: if isinstance(item, str): words.append[item] else: sum += item return str(sum) + ''.join(words)

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

instances.py
def cobiner(list_of_datas):
    sum=0
    words = []
    for item in list_of_datas:
        if isinstance(item,str):
            words.append[item]
        else:
            sum += item
    return str(sum) + ''.join(words)        

1 Answer

Steven Parker
Steven Parker
177,671 Points

There are a few issues here:

  • the method here is named "cobiner" but the instructions ask for "combiner" (with an "m")
  • the argument for the "append" method is in brackets but it should be parentheses :point_left:
  • the stringified numbers should be concatenated to the end of the words instead of the beginning

:point_right: The second issue was the cause of the "not subscriptable" error.