Nice way of getting items from two lists

SBrunning at SBrunning at
Wed Mar 10 18:51:17 CET 2004

> From: C GIllespie [mailto:csgcsg39 at]
> I have two equal size lists - list1, list2. Basically, each 
> item in list 1
> has a partner in list2. I was wanting to do something like
> So if:
> list1=['x','y','z']
> list2=[1,2,3]
> then if I did this 'for loop'
> for name, value in list1,list2:
>     print name, value
> I would get
> x,1
> y,2
> z,3

for name, value in zip(list1, list2):
    print name, value

Simon B.
simon at 

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