[Tutor] Counting help

Scott Oertel me at scottoertel.info
Wed Aug 24 10:40:19 CEST 2005


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 (date[2] == today[2]):
>>        test = regex.findall(M.fetch(int(number[1][0]) - cnt, 
>>'(BODY[HEADER.FIELDS (FROM)])')[1][0][1].rstrip())
>>        cnt += 1
>>        if (nameofsender != []):
>>            print nameofsender[0]
>>            listofnames = nameofsender[0], listofnames
>>    
>>
>
>I think you want 
>  listofnames.append(nameofsender[0])
>which will add nameofsender[0] to the list. What you have -
>  listofnames = nameofsender[0], listofnames
>is making a tuple (a pair) out of the new name and the old list, and assigning it to listofnames. Kind of like CONS in LISP - but Python lists are more like arrays than like LISP lists.
>
>Kent
>
>  
>
>>        else:
>>            no_name += 1
>>    else: break
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>    
>>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>  
>
Thank you everyone, this is exactly it, I'm going to take that link from 
byron and read up on dicts/lists.

-Scott Oertel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050824/0edef197/attachment.htm


More information about the Tutor mailing list