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


#1

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.


#3

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.


#4

Thank you for explaining.


#5

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