TypeError: 'list' object is not callable


#1

Im having the same issue.

My error message is:

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

my code is:

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

print join_strings(n)

Is it me or does the console just is not clear on what the error is in the code?
And my code is indented the preview here just messes it up and i cant figure out how to edit the message with the correct tags to add the indents. How about a tag that does not mess up indents instead of a "preformatted text "tag thats messes up the whole layout.


Code doesn't pass
#2

Here's a link to formatting your code - discuss.codecademy.com/t/using-backticks-to-format-your-code/3697/2 :slightly_smiling:

And you have error in this line:

result += words(i)

it should be:

result += words[i]

#3

OOOOOOOOOOOOO man I always feel so stupid when the error is pointed out to me.

I need to refresh my basic dictionary rules. [] for dictionaries. () for parameters.

Thanks.


#4

2 posts were split to a new topic: "Oops, try again. join_strings(['x', 'y', 'z', 'a']) returned 'x' instead of 'xyza'