list manipulation

Joe Riopel goon12 at gmail.com
Tue Apr 22 17:07:32 EDT 2008


On Tue, Apr 22, 2008 at 4:55 PM, DataSmash <rdh at new.rr.com> wrote:
> Hello,
>
>  I have a list that looks like this:
>  roadList = ["Motorways","Local","Arterial"]
>
>  I want to apply some code so that the output looks like this:
>  "Motorways;Local;Arterial"
>  How can this be done with the LEAST amount of code?

Not sure if it's LEAST amount of code, or the best, but it works.

>>> li = ["Motorways","Local","Arterial"]
>>> '\"%s\"' % (''.join(['%s;' % (x,) for x in li]),)
'"Motorways;Local;Arterial;"'
>>>



More information about the Python-list mailing list