if n == 1:
    print('*')
else:
    print('*' * n)
for i in range(n - 3, -1, -1):
    print('*{}*'.format(' ' * i))
print('*')
How to print this pattern? I cannot get the logic for eliminating the middle part