"Using strings in lists in fnuctions"



When I click Save and Submit it just says:
Oops, try again. join_strings(['x', 'y', 'z', 'a']) returned 'MichaelLieberman' instead of 'xyza'

I have no Ideas what I did wrong please help me


n = ["Michael","Lieberman"]
# Add your function here
def join_strings(words):
    result = ""
    for i in range(len(n)):
        result += n[i]
    return result
print join_strings(n)



def join_strings(words):

you declare your function, and give it a parameter (words)

then when you call the function:

print join_strings(n)

you pass n as argument. the argument is copied into the parameter. So you should loop over the parameter inside the function, this way your function works for any list passed as argument when calling the function


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