Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python

Abby Schoeller
PLUS
Abby Schoeller
Courses Plus 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 68,082 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!!