Iterate over a specific column in a dictionary in Python -
i'm trying iterate on second column (first index) in dictionary similar to:
dict = { "me": [("blue", 37, 1, 2, "up", "left")], "you": [("green", 03, 3, 4, "up", "right"), ("red", 29, 5, 6, "down", "right"), ("yellow", 35, 7, 8, "straight", "down")], "them": [("black", 08, 9, 10, "up", "up"), }
and retrun largest value. have is:
c in dict[1:2]: x = 0 if c > x: x = c return x
i'm getting unhashable type error. know has how code iterates on dictionary i'm stuck on how fix it. language python. wrong here? appreciated!
have tried using dict.iteritems() iterate on key-value pairs?
ex:
for key, val in dic.iteritems(): print "key: " + str(key) + "\t value:" + str(val)
Comments
Post a Comment