Python Object-Oriented Python Inheritance Instances

Abby Schoeller
PRO
Abby Schoeller
Pro Student 6,187 Points

Joining two lists

I think I am stuck at the bottom, trying to concatenate and print out the joined lists.

instances.py
words = []
numbers = []

def combiner(*args):
    for arg in args:
        if isinstance(arg, str):
            words.append(arg)
        if isinstance(arg, float):
            numbers.append(arg)
    full_list = words + numbers.sum()
    print(full_list.join())

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 59,027 Points

You are on the right path. There are a few items to fix up.

  • remove the * from the args parameter. The function input will be a single list. By using the *, the function packets the entire list into the first element of the tuple *args: (["apple", 5, "dog", 8.2], ). This means the for loop will be seen a list instance. It might be better to change the param name to items and use for item in items
  • the empty list initialization should be inside the function definition
  • remember to check for integers too: isinstance(arg, int)
  • the list numbers does not have a sum method. Use sum(numbers) instead
  • to join the words list into a single string, use "".join(words)
  • be sure to add a string version of the sum to the end of the word string
  • return the final value. Using print is not seen by the challenge checker

Post back if you have more questions. Good Luck!!