how do i change from string to list
Ivo Woltring
TheDolphin at ivonet.nl
Sun Oct 24 17:21:25 EDT 2004
I agree completely!
Didn't know the list() though.
But all work so my answer is just as valid as yours
;-))
Ivo
"Ivo Woltring" <TheDolphin at ivonet.nl> wrote in message
news:417bf196$0$771$3a628fcd at reader20.nntp.hccnet.nl...
> str='spot'
>
> lst = [] # declare the list first
> for letter in str:
> lst.append(letter) # append to the list
>
> print lst
>
> result: ['s', 'p', 'o', 't']
>
> cheerz,
> Ivo.
>
>
> "john" <miodio67 at hotmail.com> wrote in message
> news:99ca2e2f.0410241005.39a4f1db at posting.google.com...
> > I have the following
> >
> > s = "spot"
> >
> > which I would like to change to a list
> >
> > l = ['s','p','o','t']
> >
> > I have tried l = eval(s) but I get the error
> >
> > File "<string>", line 1, in ?
> > NameError: spot
> >
> > thank you all for your time
>
>
More information about the Python-list
mailing list