12. Lists and Functions



<Below this line, add a link to the EXACT exercise that you are stuck at. The query string (? and beyond) may be truncated.>

<In what way does your code behave incorrectly? Include ALL error messages.>

<What do you expect to happen instead?>


n = [“Michael”, “Lieberman”]

Add your function here

def join_strings(words):
result = “”
for i in range(len(words)):
return result

print join_strings(n)

“”"“Hey Guys I’ve already completed the course I just wanted to figure out why the .append() method doesn’t seem to work. Please Help.”""

<do not remove the three backticks above>


your result is empty string and you are appending empty string. Maybe you want to append i?


Thanks! Have just tried your method. But now its giving me this error:

Oops, try again. join_strings([‘x’, ‘y’, ‘z’, ‘a’]) returned ‘’ instead of ‘xyza’.


Tried it on IDLE too


append to result and not to words:



You need to append your i to result to get string



I’ve tried the results.append(i) method getting new error. @knezknele @tomaszd7

Oops, try again. join_strings([‘x’, ‘y’, ‘z’, ‘a’]) resulted in an error: ‘str’ object has no attribute ‘append’


And also trying to run this other code on IDLE please tell me what I’m dooing wrong. I want to create a single list out of the sub lists.

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]

def flatten(lists):
results =
for lists in n:
for numbers in lists:
result += lists[numbers]
return results

print flatten(n)


your variable is called result not results


Haha yea that was a typo. I wrote result but still gave same error.


Found solution to that other piece of code of concatenating sub lists. but still stuck on joining the strings. @knezknele @tomaszd7


Oh, your return should be outside of the loop and you can’t append string, it just works for list. You can try something like this

result += words[i]


Thank you very much! @knezknele