List to string
hitesh287 at gmail.com
Mon Mar 19 17:38:22 CET 2007
On Mar 19, 8:11 am, Bruno Desthuilliers <bruno.
42.desthuilli... at wtf.websiteburo.oops.com> wrote:
> 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)
Thank you guys. Yes that helped. :)
More information about the Python-list