1
except KeyError: b[x] = 1
Access count like this, of course,
>>> b["Joe Smith"]
3
>>>
Jacob Schmidt
- Original Message -
From: "Scott Oertel" <[EMAIL PROTECTED]>
To:
Sent: Tuesday, August 23, 2005 1:01 PM
Subject: [Tutor] Counting
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
listofnames = nameofsender[0], listofnames
does not add a name to a list. Rather it creates a tuple of the new
name and the list and then binds the tuple to the list name. That's why
you wind up with the lisp style list.
To add a name to the head of the list use
listofnames.insert(0, na
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
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? excuse me this is my first post to this list, I hope I
included enough inform
13 matches
Mail list logo