Digit 9
You are given
The first line of input is an integer
In the given example,
N = 4.So, the output should be
* * * *
* *
* *
* * * *
*
*
* * * *
Sample Input 1
4
Sample Output 1
* * * *
* *
* *
* * * *
*
*
* * * *
Sample Input 2
5
Sample Output 2
* * * * *
* *
* *
* *
* * * * *
*
*
*
* * * * *
n = int(input())
rows = n*2-1
s = ''
for i in range(rows):
if i == 0 or i == (rows//2) or i == (rows - 1):
s += '* ' * n + '\n'
elif i < (rows//2):
s += '* ' + ' ' * (n-2) + '* ' + '\n'
else:
s += ' ' * (n-1) + '* ' + '\n'
s = s[:-1]
print(s)
Comments
Leave a comment