The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Not seeing your question? It may still have been asked before – try () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
(1)result += word … Where result and word are strings,
… first evaluates result to obtain a value (i.e., find out what string is assigned to it.)
Then “adds” (concatenates) the value (assigned string) of word to that value. That means that the value of word is joined to the right side of the string result to produce a new string
Then the value of the new string is assigned to the variable result
result = 'abc'
word = 'xyz'
result += word
print(result)
Output:
abcxyz
Now, if in (1) above, you switch result and word , what will happen? Try it!!!
I am having difficulties understanding how this function works. When I wrote it out originally it only drew the first name, probably due to the fact that I was using the term “item” in my iteration instead of the term “word” but I’m unsure of that being the cause or not.
And thank you for explaining how the “result += word” strings work in this function. I kept tripping over it.
Could you post a code sample? I personally suspect your problem may be that you incorrectly indented the return statement since I had the exact same problem. Try deleting two spaces preceding it.
I doubt using result += item is your problem, since after fixing the aforementioned indentation, I passed using result += string.