Using strings in lists in functions


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
Oops, try again. join_strings(['x', 'y', 'z', 'a']) resulted in an error: string indices must be integers, not list


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

result += word

if you insist on using indexes, use range()


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