<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Scott Oertel wrote:
<blockquote cite="mid430B7B2C.2030003@scottoertel.info" type="cite">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
Byron wrote:
<blockquote cite="mid430B7983.8050103@christianfreebies.com"
type="cite">
<pre wrap="">Luis N wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.
l = ['a list of names']
d = {}
for name in namelist:
if d.has_key(name):
x = d.get(name)
d[name] = x + 1
else:
d[name] = 1
</pre>
</blockquote>
<pre wrap=""><!---->
100% agreed. I have used this approach before and it works great...
Byron
</pre>
</blockquote>
Thanks for the snipplet, it's perfect for what I'm doing, I wasn't
aware of the has_key() or get(), this is very usefull.<br>
<br>
<br>
-Scott Oertel<br>
<br>
<br>
<br>
<br>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Tutor maillist - <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
</blockquote>
The next problem I have though is creating the dict, <br>
<br>
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' )))<br>
<br>
<br>
listofnames = []<br>
while (cnt < number[1][0]):<br>
if (date[2] == today[2]):<br>
test = regex.findall(M.fetch(int(number[1][0]) - cnt,
'(BODY[HEADER.FIELDS (FROM)])')[1][0][1].rstrip())<br>
cnt += 1<br>
if (nameofsender != []):<br>
print nameofsender[0]<br>
listofnames = nameofsender[0], listofnames<br>
else:<br>
no_name += 1<br>
else: break<br>
<br>
<br>
</body>
</html>