Using strings in lists in functions


#1

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



    print join_strings(n)

i dont know wahts wrong with that code
error:
Oops, try again. join_strings(['x', 'y', 'z', 'a']) resulted in an error: string indices must be integers, not list


#2

word holds the items in the list, not indexes. You can just do:

result += word

if you insist on using indexes, use range()


#3

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