Dictionary question.

Simon Brunning simon.brunning at gmail.com
Thu Apr 21 06:17:01 EDT 2005


On 21 Apr 2005 02:47:42 -0700, hawkesed <olaamigoquepasa at hotmail.com> wrote:
>   I am semi new to Python. Here is my problem : I have a list of 100
> random integers. I want to be able to construct a histogram out of the
> data. So I want to know how many 70's, 71's, etc. I can't figure out
> how to do this. A dictionary is supposedly can do key value pairs
> right? I want to be able to see if say 75 is in the data structure, and
> what its value is, then increment its value as I go through the list
> finding items.
>   I am sure there is a way to do this. Is a dictionary what I should be
> using? Thanks for any help. Hope this makes sense, its getting very
> late here.

Sounds like homework, so I'll just say that yes, a dictionary would be
ideal for what you are trying to do.

-- 
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list