-2

** I want to use two for-loops instead of two while-loops **

i = 7
while i >= 1:
    j = i
    while j <= 7:
        print(j, end ="  ")
        J += 1
    i -= 1
    print()
Aamir
  • 2,380
  • 3
  • 24
  • 54

1 Answers1

1

The following is the for-loop equivalent:

for i in range(7, 0, -1):
    j = i
    for j in range(i, 8):
        print(j, end="  ")
    print()

The key is the correct use of range(start, stop, step). See also this.

user2390182
  • 72,016
  • 6
  • 67
  • 89