I found a weird result of this below code on my project (below code is equivalent to the code in my project since I have to remove parts that are irrelevant to the question):
import random
random.seed(9000)
...
list1 = [0, 1]
list2 = []
set_diff = set(list1) - set(list2)
print( set_diff )
list_diff = list( set_diff )
print( list_diff )
print( random.choice( list_diff ) )
The result is unstable since the order (as printed) of set_diff is unstable (set is supposed to have no order). Result could be:
{'0', '1'}
['0', '1']
1
or
{'1', '0'}
['1', '0']
0
in different runs. Could anyone please explain why? Thanks!