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


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



More information about the Python-list mailing list