Using strings in lists in functions


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/5?curriculum_id=4f89dab3d788890003000096#


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


n = ["Michael", "Lieberman"]
# Add your function here

def join_strings(words):
    result=""
    for i in range(len(words)):
        result= result + words(i)
    return result

print join_strings(n)


#2

Let's go through this using the errors indicated.

Your use of the len and range in-built here

is not cool. You could simply for loop i in words.

for i in words:

Then, go on to

result += i

or

result = result + i

You should look at this Built-in Functions


#3

If you're using the range(len(words)) option for doing this, then you need to use square brackets in words[i] instead of parentheses:

for i in range(len(words)):
    result += words[i]
return result

#4

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