Attention: Python Set is Changing From Time to Time

Hongtao Hao / 2022-08-12

I just learned this several days ago: set in python is unsorted and changes from time to time.

For example:

a = ['a', 'b', 'b', 'c', 'd', 'd', 'e']

If you run the codes twice (in two different notebooks or scripts), the results are different. To solve this problem:

ls = list(set(a))

Last modified on 2022-10-30