16/18

n = [“Michael”, “Lieberman”]

Add your function here

def join_strings(words):
result = “”
for words in n

print join_strings(n)

help me out please?

Your code looks a little bit wrong. I don’t see that your function returns result. Also block separation is also absent.

Workable example is:

n = [“Michael”, “Lieberman”]

Add your function here

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

6 Likes

how do you add them together?

hey you used the result += words[i] to add them it will go to michael add that to result then go to lieberman and add that to result. Hope that helped

all if you wanna do space in between in michael before the end quote add a space

I don’t understand what I am doing wrong?

n = [“Michael”, “Lieberman”]
def join_strings(words):
result=""
for i in range(len(words)):
result+=words[i]
return result

Please HELP!!!

I figured it out! I wasn’t indenting properly

1 Like

Could somebody hlep me?
I don’t know what is wrong?

n = [“Michael”, “Lieberman”]
def join_strings(words):
-tab- result = “”
-tab- for i in words:
-tab-tab- result += words[i]
-tab- return result
print join_strings(n)

Thank you very much.

for i in words: i takes the items inside list and not the index (i=“Michael”,“Lieberman”)
result+= words[i] is wrong
the correct answer is result+=i

if you do the iteration with:
for i in range(len(words)): then result+= words[i] is correct

Hope I helped!!!

2 Likes

Thank you very much. Now it is OK.

please tell me this answer ive been stuck for a week and a half…

how about no use git hub it has all the answers
https://github.com/BugraBalci/codecademy-exercise-answers/tree/master/Python/Conditionals%20%26%20Control%20Flow

for i in range(len(words)):
    result = result.join(words)

It works.,
this is the actual code we have to use… should not use + function…

2 Likes

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)

My code is still returning error message -
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)

I am wondering about the same thing. I’ve used (indents are no problem):

`n = [“Michael”, “Lieberman”]
def join_strings(words):
result = “”
for words in n:
result += words
return result

print join_strings(n)`

And it’s returning MichaelLieberman, but I also get a “Oops, try again. join_strings([‘x’, ‘y’, ‘z’, ‘a’]) returned ‘MichaelLieberman’ instead of ‘xyza’” error… And I have no idea where is the problem… Maybe you got passed it already and know why?

you should use this code
when you define a function, you should define it as an universal one

1 Like

Nobody in this thread knows what they are talking about