Python Object-Oriented Python Inheritance Instances

Blessing Nyamayedenga
Blessing Nyamayedenga
6,163 Points

instances

guys im still having trouble here please help

instances.py
def combiner(str_num):
    str_num = ["mom", "eldrine", "kiki",8, 5, 8, 5, 2, 3]
    nums = []
    strings = []
    for item in str_num:
        if isinstance(item, str):
            strings.append(item)
        elif isinstance(item,(int,float)):
            nums.append(item)
    nums = sum(nums)
    strings = "".join(strings)       
    return strings + str(nums) 

2 Answers

You are so close!

Your function, combiner, takes an argument, (str_num). However, on line 2, you override the value of str_num and give str_num the value ["mom", "eldrine", "kiki",8, 5, 8, 5, 2, 3].

So when the function is run, no matter what is provided as str_num, the output will always be "momeldrinekiki31".

Remove line 2 and it will work.