turn list of letters into an array of integers

Demian Brecht demianbrecht at gmail.com
Wed Oct 24 01:51:26 EDT 2012


On 2012-10-23, at 10:45 PM, Demian Brecht <demianbrecht at gmail.com> wrote:

>>>> list_ = [d[c] for c in s.strip('\n').split()]
>>>> list_
> ['1', '2', '1', '2', '2', '1']


Of course, if you want these to be ints, then you can either change the format of your int list, or map(int, list_) if you don't have control over it.

Demian Brecht
@demianbrecht
http://demianbrecht.github.com







More information about the Python-list mailing list