Name and name would represent two completely distinct keys in the dictionary. : Introduction « Dictionary « Python Tutorial






numbers = ('1','2','3','4','5','6','7','8','9','0')
letters = ('a','b','c','d','e','f')
punct = ('.', '!', '?')
charSetDict = {numbers:[], letters:[], punct:[]}

def display_cset (cset):
    print
    for x in cset.items():
        if x[0] == numbers:
            print "Numbers:"
        elif x[0] == letters:
            print "Letters:"
        elif x[0] == punct:
            print "Puctuation:"
        else:
            print "Unknown:"
        print x[1]


cSet = raw_input("Insert characters: ")
for c in cSet:
    for x in charSetDict.keys():
        if c in x:
            charSetDict[x].append(c)
            break;

display_cset(charSetDict)








8.1.Introduction
8.1.1.Dictionary Syntax
8.1.2.To loop over the keys of a dictionary, you can use a plain for statement
8.1.3.Simple one to one dictionary
8.1.4.One to many dictionary
8.1.5.Constructing a Dictionary
8.1.6.Many to many dictionary
8.1.7.Adding a Value to a Dictionary
8.1.8.Name and name would represent two completely distinct keys in the dictionary.
8.1.9.Add new key and value
8.1.10.Change value for existing key