Ezio Melotti added the comment: I think you are misunderstanding how join works. join is useful when you have a list of strings, and you want to combine them together, possibly specifying a separator. The syntax is separator.join(list_of_strings), for example: >>> '-'.join(['foo', 'bar', 'baz']) 'foo-bar-baz'
What you are doing is: new_item = new_item.join((item + ';')) Here new_item is the separator, and (item + ';') is a string (a sequence of characters), so the separator is added between each character of the string: >>> '-'.join('foobarbaz') 'f-o-o-b-a-r-b-a-z' new_item will grow bigger and bigger, and since you keep adding it between each character of the item, Python will soon run out of memory: >>> 'newitem'.join('foobarbaz') 'fnewitemonewitemonewitembnewitemanewitemrnewitembnewitemanewitemz' You probably want to add the items to a new list, and after the for loop you just need to do '; '.join(new_list_of_items), or, if you want a ; at the end, you can add (item + ';') to the list and then use ' '.join(new_list_of_items). I also suggest you to use the interactive interpreter to experiment with join. ---------- nosy: +ezio.melotti resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30305> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com