dictionaries

Zach Shutters zshutters at comcast.net
Fri Sep 10 14:02:09 EDT 2004


ok, i am trying to learn how to use dictionaries and i am having trouble 
with this code:

def function1():
    print "function1"

def function2():
    print "function2"

dict = {"1":function1,"2":function2}
x = input ("1 or 2?")

dict[x]()







More information about the Python-list mailing list