how do i change from string to list
Michael Hoffman
m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Sun Oct 24 15:10:41 EDT 2004
More information about the Python-list mailing list
Sun Oct 24 15:10:41 EDT 2004
- Previous message (by thread): how do i change from string to list
- Next message (by thread): how do i change from string to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ivo Woltring wrote:
> str='spot'
>
> lst = [] # declare the list first
> for letter in str:
> lst.append(letter) # append to the list
>
> print lst
I just would have used list("spot").
> result: ['s', 'p', 'o', 't']
Same result but faster, more transparent, and with a lot less code.
Also, please don't top-post.
--
Michael Hoffman
- Previous message (by thread): how do i change from string to list
- Next message (by thread): how do i change from string to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list