0

I wondered while performing some set related operation. below is my scenario, I have two sets 'a' and 'b', and I'm calculating the difference.

a = {1,2,3,5}
b = {5,6,7,8}
print(b-a)

and I have another two set 'c' and 'd' and same, I'm calculating the difference of that two sets also.

c = {1,2,3,4,0}
d = {6,7,8,9,5}

print(d-c)

The result of above two operations is like :

{8, 6, 7}          #Expecting {6,7,8}, why this sequence changed ?
{5, 6, 7, 8, 9}

But here I found that the sequence of the first result is changed. while other is in the correct sequence.

Abhijit Kumbhar
  • 923
  • 3
  • 23
  • 49

1 Answers1

0

From the docs

A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries.

aydow
  • 3,673
  • 2
  • 23
  • 40