16/18 problem


#1

I'm getting an error that join_strings(['x', 'y', 'z', 'a']) returned ['', 'x', 'y', 'z', 'a'] instead of 'xyza' and I don't understand why... can anyone help? My code is:

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

#2

I'm not sure why you're combining words and rap but to help you... change your list to look like
n = ["words","rap"]
Inside your function you need to include the i after words and the return should be outside of the for loop but still inside the function. Then we you call your function use n as the argument not the individual strings
So the whole thing should look like:
n = ["words", "rap"]

def join_strings(words):
result = ""
for i in range(len(words)):
result += words[i]
return result
#make sure everything is properly indented
print join_strings(n)


#3
 n = ["Michael", "Lieberman"]
    # Add your function here
    def join_strings(words):
        result = [""]              #  here you hav created a list instead of an empty  string i.e "" 

 for i in range(len(words)):          
            result += words     # So here the first word adds to list  like ["Michael"] 
                                   and the second one adds to it the list *result* like ["Michael,"Liberman"]         
            return result          instead of adding to *string*  "Michael"
                                 # To solve the error remove the square brackets   
    print join_strings("words" "rap")

instead you should write result


#4

your indentation is wrong for return result


#5

Thanks for the help!