I want to store all pairs which are sum of N as tuples.
Here is my code so far:
m = []
l = []
degree = 9
for i in range(0, degree):
m += [degree - i];
l += [i]
pairs = (m[i]),(l[i])
pairs
This code return only last pair:
(1, 8)
What I want is this:
(9, 0),(8, 1),(7, 2),(6, 3),(5, 4),(4, 5),(3, 6),(2, 7),(1, 8)
How to do it?
>Solution :
You can do it this way by defining a new pair’s list, appending it inside the loop, and finally printing.
m = []
l = []
degree = 9
pairs = []
for i in range(0, degree):
m += [degree - i];
l += [i]
pairs.append((m[i],l[i]))
print(pairs)