210k views
1 vote
Write a program that prints the following pattern. You must use a loop to do this and you may not output the pattern manually using print statements. You should use at max 2 print statements. write code for python

Write a program that prints the following pattern. You must use a loop to do this-example-1

1 Answer

1 vote

Answer:

there a two loops,

1. for loop

2. while loop

using a for loop

for i in range(6):

print("* " * i)

for i in range(4, 0, -1):

print("* " * i)

using a while loop

i = 0

while i < 6:

print("* " * i)

i += 1

while i > 0:

print("* " * i)

i -= 1

hope this helps!

User Andriy M
by
3.5k points