W pattern with *
Write a program to print W pattern of N lines using an asterisk(*) character as shown below.
Note: There is a space after each asterisk * character.
n = int(input())
for i in range(n):
lst = [' '] * (4 * n - i - 2)
lst[i: 2 * n - i] = ['*', ' '] * (n - i)
lst[i + 2 * n - 2:4 * n - i - 2] = ['*', ' '] * (n - i)
print(''.join(lst))
5
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
Comments
Leave a comment