[Tutor] understanding join

Steve Poe steve.poe at gmail.com
Thu Jul 31 04:31:24 CEST 2008


>
> Say I have a sequence seq and a string s, and I call s.join(seq).
> Here's what it does:
>
> s.join(seq) == seq[0] + s + seq[1] + s + seq[2] + s + ...  + seq[-2] +
> s + seq[-1]
>
> So if you call 'abc'.join('ABC'), you get:
>
>   'ABC'[0] + 'abc' + 'ABC'[1] + 'abc' + 'ABC'[2]
>
> which is:
>
>   'A' + 'abc' + 'B' + 'abc' + 'C'
>
> Hope this helps.
>
> -- 
> John.


John,

Your explanation is very help. It does make be wonder the usefulness
of join with strings. Do you have a practical example/situation?

Steve


More information about the Tutor mailing list