Just a short quick question on Python syntax


#1

Here is my code:

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

From my errors, I'm operating on this string/ list of strings in an incorrect way, as is apparent to my error. So what is the correct syntax for appending strings? I know, right? Its a pretty simple question about syntax, but believe it or not, it even stumped the experienced Python Programmers.


#2

I would make an array before result. Then you append the strings to the array. After that you make result a joined version of the array. Like this:

def join_strings(values):
    basis = []
    for num in range(len(values)):
        basis.append(words[num])
    result = "".join(basis)
    return result