I have this piece of code that is working fine in python 2.7.
“dist” is a dictionary of number and “min_dist” is just a number.
for v in vertices:
if dist[v.node_id] < min_dist:
min_dist = dist[v.node_id]
cur_min = v
Now I am trying to run it under python 3.2 and it gives me this error:
if dist[v.node_id] < min_dist:
TypeError: unorderable types: dict() < int()
What is wrong with my code in python 3.2?
distis not a “dictionary of number”, it is a dictionary of dictionaries of numbers. Your code should not work even in 2.x.