Python Object-Oriented Python Inheritance Instances

Please help me understand this question

One argument i have to take is it the list Or i just have to return the list
def combiner(self):
    return print(["apple" + 7.9 + "snake" + 9])

1 Answer

Ken Stone
Ken Stone
21,668 Points

You need to create a function that accepts a list

Here the params parameter is a list

then for each item in the list determine if it's a string or a number

If it's a sting concat it with the other strings

if a number add it to the total

then finally return the concat of the string with the number coerced as a string

def combiner(params):
  ret_val = ''
  total = 0

  for param in params:
    if(isinstance(param, str)):
      ret_val += param
      total += param

  return ret_val + str(total)