List to string

Hitesh hitesh287 at gmail.com
Mon Mar 19 12:38:22 EDT 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. :)

hj





More information about the Python-list mailing list