Re: [Tutor] Counting help

2005-09-02 Thread Jacob S.
I'll do this again, just because I like sending email. Very similar to Alan G.'s -- but with the do first, ask forgiveness later a = ["Joe Smith", "Joe Smith", "Jack Smith", "Sam Love", "Joe Smith"] b = {} for x in a: try: b[x] += 1 except KeyError: b[x] = 1 Access count like this, of co

Re: [Tutor] Counting help

2005-08-24 Thread Scott Oertel
Kent Johnson wrote: Scott Oertel wrote: The next problem I have though is creating the dict, i have a loop, but i can't figure out how to compile the dict, it is returning this: ('Joey Gale', ('Scott Joe', 'This is lame' ))) listofnames = [] while (cnt < number[1][0]): if

Re: [Tutor] Counting help

2005-08-23 Thread Byron
Hi Scott, The site ( http://www.greenteapress.com ) has a wonderful tutorial on it for Python that quickly teaches one (within a few minutes) how to work with dictionaries. I would highly recommend that you check it out. It's well worth it... Byron _

Re: [Tutor] Counting help

2005-08-23 Thread Kent Johnson
Luis N wrote: > Ideally, you would put your names into a list or dictionary to make > working with them easier. If all you're trying to do is count them > (and your list of names is long), you might consider a dictionary > which you would use like so: > > #This is just the first thing I considered

Re: [Tutor] Counting help

2005-08-23 Thread Kent Johnson
Scott Oertel wrote: > The next problem I have though is creating the dict, > > i have a loop, but i can't figure out how to compile the dict, it is > returning this: ('Joey Gale', ('Scott Joe', 'This is lame' ))) > > > listofnames = [] > while (cnt < number[1][0]): > if (date[2] == today[2

Re: [Tutor] Counting help

2005-08-23 Thread Alan G
>I have extracted a list of names, i.e. > > "Joe Smith" > "Joe Smith" > "Jack Smith" > "Sam Love" > "Joe Smith" > > I need to be able to count the occurances of these names and I > really don't have any idea where to begin. The classic way to do this kind of thing is with a dictionary: names =

Re: [Tutor] Counting help

2005-08-23 Thread Scott Oertel
Scott Oertel wrote: Byron wrote: Luis N wrote: Ideally, you would put your names into a list or dictionary to make working with them easier. If all you're trying to do is count them (and your list of names is long), you might consider a dictionary which you would us

Re: [Tutor] Counting help

2005-08-23 Thread Scott Oertel
Scott Oertel wrote: Byron wrote: Luis N wrote: Ideally, you would put your names into a list or dictionary to make working with them easier. If all you're trying to do is count them (and your list of names is long), you might consider a dictionary which you would us

Re: [Tutor] Counting help

2005-08-23 Thread Scott Oertel
Byron wrote: Luis N wrote: Ideally, you would put your names into a list or dictionary to make working with them easier. If all you're trying to do is count them (and your list of names is long), you might consider a dictionary which you would use like so: #This is just the first

Re: [Tutor] Counting help

2005-08-23 Thread Byron
Luis N wrote: >Ideally, you would put your names into a list or dictionary to make >working with them easier. If all you're trying to do is count them >(and your list of names is long), you might consider a dictionary >which you would use like so: > >#This is just the first thing I considered. > >

Re: [Tutor] Counting help

2005-08-23 Thread Luis N
On 8/23/05, Scott Oertel <[EMAIL PROTECTED]> wrote: > I have extracted a list of names, i.e. > > "Joe Smith" > "Joe Smith" > "Jack Smith" > "Sam Love" > "Joe Smith" > > I need to be able to count the occurances of these names and I really > don't have any idea where to begin. > > Any ideas? exc