Using strings in lists in functions: Need help how it is working


n = ["Michael", "Lieberman"]

Add your function here

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

print join_strings(n)

Need help how it is working, giving the output not understood.


We're given a list of words. which we iterate over in the for loop. Starting with an initial empty string, each word is concatenated to that string.


"" + word1

"" + word1 + word2

The final result will be string with no spaces between words.


Thank you for explaining.


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