I want to create two random sets and compare them to two other sets. The programm should stop when both sets are the same as the other two sets. This is a boiled down version of the code i'm having trouble with:
import random
random.seed()
a = set()
b = set()
c = set()
d = set()
for i in range(3):
a.add(random.randint(1,10))
b.add(random.randint(1,10))
while a!=c and b!=d:
c.clear()
d.clear()
for i in range(3):
c.add(random.randint(1,10))
d.add(random.randint(1,10))
print(a,b)
print(c,d)
The exact line with my problem:
while a!=c and b!=d:
With "and" the loop already stops when just one pair of sets are the same. When i switch the "and" for "or" it does exacly what i want, i just don't understand why? Can somebody please explane.