What is the most effective method for rewriting this code in a manner that is both concise and elegant?
def xy():
xset = {x for x in range(-4, 6)}
yset = {y for y in range(-3, 4)}
A = {(x, y) for x in xset for y in yset if 2*x - y == 0}
B = {(x, y) for x in xset for y in yset if 3*x + y == 0}
return A&B, A|B
print(xy())
2 posts - 2 participants