I was toying around with Python and I ran the following:
for i,j in (range(-1, 2, 2),range(-1, 2, 2)):
print(i,j)
I expected this to print
>> -1, -1
>> 1, 1
However what came out was
>> -1, 1
>> -1, 1
(1) Why is this the output and what is going on behind the scenes
(2) If I wanted to get all combinations of -1 and 1 (which are(-1,-1), (-1,1), (1,-1), and (1,1)) I know that I can use a nested for loop
for i in range(-1,2,2):
for j in range(-1,2,2):
print(i,j)
However is there a way to do this in one line with one for loop call (what I was trying to do with the original code)?