turn list of letters into an array of integers
Demian Brecht
demianbrecht at gmail.com
Wed Oct 24 01:45:07 EDT 2012
On 2012-10-23, at 10:23 PM, seektime <michael.j.krause at gmail.com> wrote:
> My question is how can I turn "seq" into a python array?
Something like this perhaps?:
>>> alpha = ('a', 'b')
>>> numeric = ('1', '2')
>>> L = ['a b a\n', 'b b a\n']
>>> s = ' '.join(L)
>>> d = dict(zip(alpha, numeric))
>>> list_ = [d[c] for c in s.strip('\n').split()]
>>> list_
['1', '2', '1', '2', '2', '1']
Demian Brecht
@demianbrecht
http://demianbrecht.github.com
More information about the Python-list
mailing list