Using strings in lists or functions


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


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


ok thank you

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

i should have used "" instead "_"


thank you


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


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


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