Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Using a for loop:
for i in range(5):
    print('*'*(i+1))

Output:

*
**
***
****
*****
  1. Using a while loop:
i = 1
while i <= 5:
    print('*'*i)
    i += 1

Output:

*
**
***
****
*****
  1. Using nested loops:
for i in range(5):
    for j in range(i+1):
        print('*', end='')
    print()

Output:

*
**
***
****
*****