[Tutor] viewkeys,viewvalues,viewitems : Use Cases

Dave Angel davea at davea.name
Wed Feb 26 19:55:53 CET 2014


 Santosh Kumar <rhce.san at gmail.com> Wrote in message:
> 
want to understand about where to use ,
viewkeys()
viewvalues()
viewitems()

..............

Sometimes you want to loop through a dict,  doing something with
 each of the items.  For example you want to generate a report.
 

Suppose you have a dict where the keys are names and the values
 are grades. Perhaps you want to calculate the average grade.  You
 don't care about names,  so you loop through values.

Or you want to check how many names begin with J. Loop through the
 keys. 



-- 
DaveA



More information about the Tutor mailing list