0

below is my code, and when I print or use the Python set, it automatically re-sort my item, why does this happen?

a = {9,40,49}
print(a)

{40, 9, 49}

Below is notebook printed image.

Jupyter Notebook Auto Re-sorting

Wing Shum
  • 472
  • 6
  • 19

1 Answers1

1

Sets are an unordered data structure. However, depending on your use case, it might be appropriate to use a different data type such as list.

sebjose
  • 36
  • 3