Hi Alan and Ken,

I think know the difference between using items() vs. iteritems() and
their equivalent for keys and values. I notice Ken suggests iteritems(),
while Alan suggests items() only.

Does one approach have an advantage over the other?
Should we use only one of them favorably?

Thanks.
Victor

On Thu, 2006-01-26 at 13:43 +0000, Alan Gauld wrote:
> > How would I modify this to just print either the values or keys?
> 
> Just ask for the values or the keys!
> 
> for value in pairs.values()
>      print value
> 
> for key in pairs.keys()
>      print key
> 
> for key,value in pairs.items()
>     print key
>     print value
> 


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

Reply via email to