[Tutor] A list of ints to a strings

Amadeo Bellotti amadeo.bellotti at gmail.com
Sat Aug 26 00:22:02 CEST 2006


thank you and like wat if i wanna write one string on one line and another
string on another line ect.

On 8/25/06, David Heiser <David.Heiser at intelliden.com> wrote:
>
>  This will work
>
>
> x = [1, 2, 3, 4, 5, 6]
>
> x = str(x)[1:-1].replace(",", '')
>
> open("filename.txt", "w").write(x)
>
>
>  -----Original Message-----
> *From:* tutor-bounces at python.org [mailto:tutor-bounces at python.org] *On
> Behalf Of *Amadeo Bellotti
> *Sent:* Friday, August 25, 2006 3:28 PM
> *To:* Tutor
> *Subject:* [Tutor] A list of ints to a strings
>
> I need to convert a list of intgers to a string so for example
>
> I have this
> x = [1, 2, 3, 4, 5, 6]
>
> I want this
>
> x = "1 2 3 4 5 6"
>
> I need this to write it to a .txt file does anyone know how to do this?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060825/8d02af3c/attachment.html 


More information about the Tutor mailing list