16. Using Strings in Lists in Functions


Not quite sure what I'm doing wrong. Help?


join_strings(['x', 'y', 'z', 'a']) resulted in an error: maximum recursion depth exceeded

Should return as MichaelLieberman

n = ["Michael", "Lieberman"]
def join_strings(words):
    for word in words:
        result = result + word
    print join_strings(n)


Remove the indentation on that line so it is outside of the function.

Inside the function, return result.


it just returns michael, not michaellieberman. How should I adjust it to make it print all items?


Be sure the return statement is not inside the loop. Let the loop finish, then return result.


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