Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Please help me understand this question

One argument i have to take is it the list Or i just have to return the list

instances.py
def combiner(self):
    return print(["apple" + 7.9 + "snake" + 9])

1 Answer

Ken Stone
Ken Stone
29,703 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
    else:
      total += param

  return ret_val + str(total)