How can I make it so that the right number is always greater than or equal to the left number?
for i in range(5):
for j in range(5):
# Right (j) should be greater than or equal to left (i)
# i.e. j >= i should always be True
print(i, j)
I tried to use: if i > j:
but I did not know how to continue it.
There are 2 basics errors:
the condition
i > j
stands fori
strict smaller thanj
. To include equality use the relationi >= j
left, right and
i
,j
are swapped: left should bei
, rightj
Then use the condition in the innermost body of the loops
Remark: you could use also the dual relation
i <= j