+ 2
Python 3 set1.update(set2) - reason for different outputs
#my python 3 code set1 = {"a", "b" , "c"} set2 = {1, 2, 3} set1.update(set2) print(set1) _________________________________ {1, 2, 3, 'b', 'c', 'a'} ____________________ {1, 'a', 2, 3, 'c', 'b'} ______________________ {'c', 1, 2, 3, 'b', 'a'} ___________________ I am getting different outputs on every run......can anyone explain its behavior
1 Antwort
+ 2
python sets are unordered and unindexed datatype, the order of the set will not be stable hence the different outputs are produced...