On 14/11/05, Roy Bleasdale <[EMAIL PROTECTED]> wrote:
> I have a list of strings and wanted to output them as a single delimited
> string.
>
> Eg
>
> ('ab','cd','ef') becomes "ab:cd:ef"

You almost had it ...

What about:

>>> lst = ['ab', 'cd', 'ef']
>>> ':'.join(lst)
'ab:cd:ef'

In general, foo.join(lst) (where foo is a string) is equivalent to:

def join(foo, lst):
  if not lst:
      return ''
  s = lst[0]
  for item in lst[1:]:
      s += foo + item
  return s

--
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to