Answer to Question #236391 in Python for raj

Question #236391

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.Input

The first line is an integer

N.Explanation

For

N = 5The output should be



* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *
1
Expert's answer
2021-09-14T18:21:31-0400
n = int(input())
for i in range(n):
    lst = [' '] * (4 * n - i - 3)
    lst[i] = lst[i + 2 * n - 2] = lst[-1] = lst[-1 - 2 * n + 2] = '*'
    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