0

I created a dictionary of sets in Python:

graph = {'A': {'B', 'C'},
     'B': {'D', 'E'},
     'C': {'F','A'}}

print(graph['A'])
print(graph['B'])
print(graph['C'])

However the order that elements are printed differ everytime I execute my code!

{'B', 'C'}
{'E', 'D'}
{'F', 'A'}

and next time:

{'B', 'C'}
{'D', 'E'}
{'A', 'F'}

What causes this inconsistent behaviour?

Lau
  • 3,260
  • 5
  • 16
  • 25

0 Answers0