Help for Python newbie
aleaxit at yahoo.com
Tue Jun 12 05:33:14 EDT 2001
"Bob Hibberdine" <bob.hibberdine at ntlworld.com> wrote in message
news:zSkV6.18764$m4.73107 at news6-win.server.ntlworld.com...
> >>> import string
> >>> mylist = ['1','2','3']
> >>> mystring = ''
> >>> mystring = mystring.join(mylist)
> >>> print mystring
> note there is no space between the items.
Right: the separator is mystring, and mystring is empty,
so the separator is empty. To use tab as the separator:
>>> mystring = '\t'
>>> mystring = mystring.join(mylist)
>>> print mystring
1 2 3
or, more simply, just:
>>> mystring = '\t'.join(mylist)
More information about the Python-list