mapping a statement over all list items
Fernando Pérez
fperez528 at yahoo.com
Fri Nov 9 21:46:22 EST 2001
> Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after
> mapping to Foo would be:
>
> Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ]
>
Is this good enough for you (never mind the bizarre prompts, I have my own
interpreter)?
In[1]:= foo=['abc-xyz', 'black-blue', '123-987']
In[1]:= [x.split('-') for x in foo]
Out[1]= [['abc', 'xyz'], ['black', 'blue'], ['123', '987']]
Cheers,
f
More information about the Python-list
mailing list