Name and name would represent two completely distinct keys in the dictionary. : Introduction : Dictionary PYTHON TUTORIALS


PYTHON TUTORIALS » Dictionary » Introduction »

 

Name and name would represent two completely distinct keys in the dictionary.


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)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Dictionary
» Introduction