List to string
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Mon Mar 19 08:11:09 EDT 2007
Hitesh a écrit :
> On Mar 18, 12:28 am, "Hitesh" <hitesh... at gmail.com> wrote:
>> Hi,
>>
>> I've a list like this..
>> str1 = ['this is a test string inside list']
>>
>> I am doing it this way.
>>
>> for s in str1:
>> temp_s = s
>> print temp_s
Why this useless temp_s var ?
>>
>> Any better suggestions?
>>
>> Thank you,
>> hj
>
> I want to cast value of a list into string..
>
There's no "cast" in Python. It would make no sens in a dynamically
typed language, where type informations belong to the LHS of a binding,
not the RHS.
I guess that what you want is to build a string out of a list of
strings. If so, the answer is (assuming you want a newline between each
element of the list):
print "\n".join(str1)
More information about the Python-list
mailing list