Write a Nested While Loop that will increment the '*' from 1 to 10.

The code below will decrement from 10 to 1.
i = 1
while(i<=11):
j = 11
while(j>=i):
print('*', end = '')
j -= 1
i += 1
print()

Respuesta :

Answer:

The program is as follows:

i = 1

while(i<11):

   j = 1

   while(j<=i):

       print('*', end = '')

       j += 1

   i += 1

   print()

Explanation:

Initialize i to 1

i = 1

The outer loop is repeated as long as i is less than 11

while(i<11):

Initialize j to 1

   j = 1

The inner loop is repeated as long as j is less than or equal i

   while(j<=i):

This prints a *

       print('*', end = '')

This increments j and ends the inner loop

       j += 1

This increments i

   i += 1

This prints a blank and ends the inner loop

   print()