0
Why is the output different?
a = {10, 20, 30, 40} b = {40, 50, 60, 70} a.difference(b) print(a) c = a.difference(b) print(c) output: {40, 10, 20, 30} {10, 20, 30}
1 Answer
+ 5
a.difference(b) => will not reflect changes by operation on original sets, it returns a new result set. So first time output is same as original set a.
2nd time, your are storing result of operation into variable c... so c is result of operation.....
Note: set doesnot maintain order of insertion of elements..