num = 5
hang = 1
while hang <= num:
if hang == 1 or hang == num:
lie = num
while lie >= hang:
print(" ", end="")
lie -= 1
count = 1
while count <= (2 * hang - 1):
print("*", end="")
count += 1
print("")
else:
lie = num - 1
while lie >= hang - 1:
print(" ", end="")
lie -= 1
print("*", end="")
count = 1
while count <= (2 * (hang - 1) - 1):
print(" ", end="")
count += 1
print("*")
hang += 1
|
|