[Tutor] understanding join

Kent Johnson kent37 at tds.net
Thu Jul 31 02:03:32 CEST 2008

> On 31/07/2008, Steve Poe <steve.poe at gmail.com> wrote:
>>  Okay, I can see the order of the join is the same as mine, but
>>  the join still seems to be out of sequence.  I am thinking it should be
>>  'abcABC' or 'ABCabc' not at the beginning, middle, and end of the
>>  original string. At least, I am trying to wrap my head around its
>>  usefulness.

Does this look useful?

In [3]: people = [ 'Tom', 'Dick', 'Harry' ]

In [4]: ', '.join(people)
Out[4]: 'Tom, Dick, Harry'

Your confusion is in thinking about the string 'ABC' as a single
entity. For the purposes of join(), it is a sequence of three letters.
The argument to join() is a sequence of strings, not a single string.


More information about the Tutor mailing list