creating sets of tuples in python
creating sets of tuples in python
mySet = set(itertools.product(range(1,51), repeat=2))
OR
mySet = set((x,y) for x in range(1,51) for y in range(1,51))
tuple
accepts only one argument. Just explicitly write in the tuple instead using parentheses.
# vvvvv
>>> positive = set((x,y) for x in range(1,5) for y in range(1,5))
>>> positive
{(1, 2), (3, 2), (1, 3), (3, 3), (4, 1), (3, 1), (4, 4), (2, 1), (2, 4), (2, 3), (1, 4), (4, 3), (2, 2), (4, 2), (3, 4), (1, 1)}