looping through a list of lists.

SBrunning at trisystems.co.uk SBrunning at trisystems.co.uk
Wed Oct 8 11:13:24 EDT 2003


> From:	saoirse_79 [SMTP:saoirse_79 at yahoo.com]
> I have a list of lists as follows:
> [['-', '-', '-', '-', '-', '-', '-', 'K', 'S', 'A', 'K'],
> ['-', '-', '-', '-', 'L', 'Q', 'Q', 'T', 'N', 'S', 'E'], 
> ['T', 'L', 'E', 'E', 'L', 'M', 'K', 'L', 'S', 'P', 'E']]
> I want to be able to read each character  and compare it with all 
> characters at the same positon in all sublists. Is this possible.
> I have tried a few different methods but nothing seems to allow me to 
> compare the sublists character by character.
 
PythonWin 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on
win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) - see
'Help/About PythonWin' for further copyright information.
>>> spam = [['-', '-', '-', '-', '-', '-', '-', 'K', 'S', 'A', 'K'],['-',
'-', '-', '-', 'L', 'Q', 'Q', 'T', 'N', 'S', 'E'], ['T', 'L', 'E', 'E', 'L',
'M', 'K', 'L', 'S', 'P', 'E']]
>>> for eggs, chips, beans in zip(*spam):
... 	print eggs, chips, beans
... 
- - T
- - L
- - E
- - E
- L L
- Q M
- Q K
K T L
S N S
A S P
K E E

HTH...

Cheers,
Simon Brunning,
http://www.brunningonline.net/simon/blog/
--LongSig




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.





More information about the Python-list mailing list