NameError when assigning dictionary values

lewst lewst at
Sun Apr 2 22:33:38 CEST 2000

This simple problem is driving my crazy.  I can't figure out why I get
a NameError with this program.

  # add each key-value pair to the dictionary and
  # then for each value, create an empty list.
  mydict = {}                         
  for key,value in [ (".", "one"), ("+", "two") ]:
      mydict[key] = value
      value = []
  print mydict
  print one,two

Whe I run this I get "NameError: one".  Why aren't my 2 empty lists
named "one" and "two" being created?

Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.

More information about the Python-list mailing list