Given an integer value
The first line of input is an integer
In the given example
N = 5. Therefore, the output should be
*
* *
* * *
* * * *
* * * * *
* * * * * *
* *
* *
* *
* *
*
N = int(input())
for i in range(1, N + 1):
for j in range(1, N - i + 1):
print(end = ' ')
for k in range(1, 2 * i):
if k == 1 or k == i * 2 - 1:
print('*', end = '')
else:
print('*', end = '')
print()
for i in range(N - 1, 0, -1):
for j in range(1, N - i + 1):
print(' ', end = '')
for k in range(1, 2 * i):
if k == 1 or k == i * 2 - 1:
print('*', end = '')
else:
print(' ', end = '')
print()
Comments
Leave a comment