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
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
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
_
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
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
>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 =
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
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
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
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.
>
>
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
11 matches
Mail list logo