16/18 what's wrong with my code


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/lists-and-functions/exercises/using-strings-in-lists-in-functions?action=lesson_resume

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

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

<What do you expect to happen instead?>

```python
def join_strings(words):
    result = ""
  for a in words:
    result = words.append(a)
    return words
  
print join_strings(n)
<do not remove the three backticks above>

#2

result = words.append(a)

why are trying to change the words list ?

here you just need to add each word ( a in the loop ) to result.

return terminates a function.If the return statement is inside of for loop then function will end at the first iteration so the return statement should be outside of for loop.now return the result variable not the words list.


#3

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