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 trialAbby Schoeller
Courses Plus Student 6,187 PointsJoining two lists
I think I am stuck at the bottom, trying to concatenate and print out the joined lists.
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
Treehouse Moderator 68,457 PointsYou 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 thefor
loop will be seen alist
instance. It might be better to change the param name toitems
and usefor 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 asum
method. Usesum(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!!