Using strings in lists in functions


#1



Traceback (most recent call last):
File "python", line 9, in
File "python", line 6, in join_strings
TypeError: 'list' object is not callable


I don't understand where I am doing wrong. please explain T.T


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

print join_strings(n)


#2

To access items of sequential data type (string, list,tuple etc) we use [] operator.
To invoke a function we use () with arguments.


#4

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