"R. Alan Monroe" <[EMAIL PROTECTED]> wrote

> Given a list of 6-letter words:
> ['abject','poetry','keypad']
>
> How do I derive this list:
> ['apk', 'boe', 'jey']

>>> a = ['abject', 'poetry', 'keypad']
>>> zip( a[0],a[1],a[2])
[('a', 'p', 'k'), ('b', 'o', 'e'), ('j', 'e', 'y'), ('e', 't', 'p'), 
('c', 'r',
'a'), ('t', 'y', 'd')]
>>> [''.join(t) for t in zip(a[0],a[1],a[2])]
['apk', 'boe', 'jey', 'etp', 'cra', 'tyd']
>>>

Does that give you any ideas?


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to