16. Using strings in lists in functions


Oops, try again. Your code looks a bit off. Check the console window for errors!

i guess there is something wrong with the append statement which i cant figure out.

Replace this line with your code. 
n = ["Michael", "Lieberman"]
# Add your function here
def join_strings(words):
    for i in range(len(words)):
    return result

print join_strings(n)


You were so close!

All you need to do for your code to work is remove words and the brackets from this line,

should be just,



it still throws an error :frowning:


Okay got it! You just have to use += instead of .append(),

result += words[i]

should work just fine. :slight_smile:


hey thanks, it worked :slight_smile:
the append function is anyways used to add anything at the last of the list. so it wasnot of any use here right?


2 posts were split to a new topic: 16. Using strings in lists in functions


That worked thanks! I am not sure why my comment has to be at least 20 characters but you are correct the return has to be on the same indent as the "for" statement.


That worked but is there a way to write it using "append"?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.