[Tutor] List to dictionary question

Morpheus morpheus at mywdo.com
Wed Dec 6 17:00:18 CET 2006

I'm new to programming, and trying to learn the Python language.  
The following code does what I want it to do, but I have not idea how it

def scanList(names,temp):
    for i in names:
        temp[i] = 0
    print temp

Names = []
temp = {}

I have a list of names (Names[]) and want to remove duplicate names in
the list.  Here is what I think is happening (please correct me if I'm
wrong, or using the wrong technical terminology):  I'm passing the
variables Names and temp as arguments to the scanList function.  The
statement (for i in names:) is an iteration going through each item in
the list.  The next statement (temp[i] = 0) is where I get confused.
Can someone please explain what is happening here.  
Thanks for your help.

More information about the Tutor mailing list