I'm doing a set difference operation in Python:
x = [1, 5, 3, 4]
y = [3]
result = list(set(x) - set(y))
print(result)
I'm getting:
[1, 4, 5]
As you can see, the order of the list elements has changed. How can I retain the list x in original format?
setsmodule. Use the builtinsettype. - Chris Morgan