-2

My code is :-

n = 6
i = 0
j = 0
while(i < n):
    while(j<n):

        print(i,j)
        j += 1

    i += 1

and the output is:-

0 0

0 1

0 2

0 3

0 4

0 5

This code should run from 0 0 to 5 5 but its not Can someone please help me .....

2 Answers2

2

you need to reset the j value after the first loop:

n = 6
i = 0
j = 0
while(i < n):
    j=0
    while(j<n):

        print(i,j)
        j += 1

    i += 1
0

It would be much better to use if the task isn't excplicitly to use nested while loops

n = 6
for i in range(n):
    for j in range(n):
        print(i, j) 
EvilTaco
  • 133
  • 2
  • 8