Answer to Question #293908 in Python for munna

Question #293908

write a program to print W pattern of n lines using an asterisk charecter (*)

1
Expert's answer
2022-02-04T07:59:22-0500
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS