Using strings in lists in functions - join_strings(['x', 'y', 'z', 'a']) returned 'MichaelLieberman' instead of 'xyza'


Hello everyone! I need your precious help.

Apparently the output is the one that is intended in the exercise, however I get the following error:

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

My code:

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)



Your function is referring to the global object, n when it should be referring to the local object, words.


@mtf Thanks very much for your quick reply!

I have made this change but the error stills.


There is still a reference to n that also needs to be changed to words.


@mtf Thanks! It's fixed!


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