While .join is more pythonic and the correct answer for this problem, it is indeed possible to use a for loop.
If this is homework (add a tag, if so!), And you should use a for loop, then that will work (although it is not pythonic, and in fact it should not be done that way if you are a professional python writer ):
endstring = "" mylist = ['first', 'second', 'other'] for word in mylist: print "This is the word I am adding: " + word endstring = endstring + word print "This is the answer I get: " + endstring
You don’t need “prints”, I just threw them there so you can see what is happening.
source share