Mar-02-2018, 01:30 PM
i am trying to get an output as follows:
The difference is the 0 being printed instead of 3 (in bold) in the 3rd column, in the piece of code i have written i have asked it to do a modulo division only if the number is greater than 3, but is it doing even if it is equal to 3? or am i missing something
Quote:1 1 1with the following code
1 1 2
1 1 3
1 2 2
1 2 3
1 2 1
1 3 3
1 3 1
1 3 2
2 2 2
2 2 3
2 2 1
2 3 3
2 3 1
2 3 2
2 1 1
2 1 2
2 1 3
3 3 3
3 3 1
3 3 2
3 1 1
3 1 2
3 1 3
3 2 2
3 2 3
3 2 1
for i in range(1, 4): for j in range(i, i + 3): if (j > 3): jdisplay = j % 3 else: jdisplay = j for k in range(j,j+3): if(k>3): kdisplay=k%3 else: kdisplay=k print(i,jdisplay,kdisplay)but i am getting output as below
Quote:1 1 1
1 1 2
1 1 3
1 2 2
1 2 3
1 2 1
1 3 3
1 3 1
1 3 2
2 2 2
2 2 3
2 2 1
2 3 3
2 3 1
2 3 2
2 1 1
2 1 2
2 1 0
3 3 3
3 3 1
3 3 2
3 1 1
3 1 2
3 1 0
3 2 2
3 2 0
3 2 1
The difference is the 0 being printed instead of 3 (in bold) in the 3rd column, in the piece of code i have written i have asked it to do a modulo division only if the number is greater than 3, but is it doing even if it is equal to 3? or am i missing something