A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/088464.html below:

string copy of a list

string copy of a listAlex Martelli aleaxit at yahoo.com
Mon Apr 16 16:10:34 EDT 2001
"Jim Richardson" <warlock at eskimo.com> wrote in message
news:slrn9dk6ga.98l.warlock at gargoyle.myth...
> I am stumped, str(listname) returns a string of list, but includes the
commas
> and [] that the list would show if printed. I want a string copy of a
list, is
> there a simple way I have missed? please? thanks

What is each item in your list?  If each item is a string, presumably what
you're asking for is to have all items joined -- either simply juxtaposed,
without separators, or maybe with (e.g.) a blank joining them?  If so,
then the join method of string objects will perform either task:

    juxtaposed = ''.join(listname)

    blankjoined = ' '.join(listname)


If your list's items are NOT strings, you presumably want to make them
into strings before joining them.  If str is acceptable for that:

    juxtap1 = ''.join(map(str, listname))

etc.  Or, you may use another function that "makes each of your items
into a string" more effectively, if there is one.


Alex




More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4