Using strings in lists in functions


#1


When I use this code it works

def join_strings(words):
    result = ""
    for i in range(len(words)):
        result = result + words[i]
    return result

but when I use this code:

def join_strings(words):
    result = ""
    for words in n:
        result = result + words
    return result

Even though the output of the both code are same, it gives the following error.

Oops, try again. join_strings(['x', 'y', 'z', 'a']) returned 'MichaelLieberman' instead of 'xyza'

Why does the second code give error message? Please help.


Replace this line with your code.


#2

where does n come from? if you would use something like:

for word in words:

if n is a variable you declared outside the function, it won't work. The exercise runs multiply strings to test your code