Using strings in lists or functions


#1


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


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


#2

Read your error message more carefully - it tells you what you returned and what you should have returned (and they are different)


#3

ok thank you

i realized i have used an extra (space) in result=" "

i should have used "" instead "_"

hence

thank you


#4

why if i use result.join(i) the code return empty string?


#5

result.append(words[i]) would work too right?


#6

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