TypeError: cannot concatenate 'str' and 'int' objects


#1

Hello,

The error message I am reading suggests that there is an interger type entering into the concatenation. I do not understand at what point in the code this is occurring. Array n contains only two strings.

Please find my code enclosed.

`n = ["Michael", "Lieberman"]

Add your function here

def join_strings(words):
result=""
for i in range(len(words)): #could this be the error source?
result = result + i
return result

print join_strings(n)`

Thank you and keep up the great work!


#2

This is, in fact, the problem. You are adding i (an int) to result (a string). What you probably intended to do was add n's element, which you would do like so:

for i in range(len(words)): #could this be the error source?
result += words[i]
return result