''' This code use python map syntax ''' myMap={} myMap["Life"]=1 myMap["is"]=1 myMap["easy"]=1 myMap["Python"]=1 ''' check map key ''' if myMap.has_key("Python"): print "Python found" ''' map length ''' print len(myMap) ''' map to tuple ''' myTuple=tuple(myMap) print myTuple ''' access map ''' for n in myMap: print n print myMap
Output:
Python found 4 ('Python', 'Life', 'is', 'easy') Python Life is easy {'Python': 1, 'Life': 1, 'is': 1, 'easy': 1}
0 comments:
Post a Comment