Answer to Question #223546 in Python for Anand

Question #223546
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 = 5

The output should be

* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *
Sample Input 1
5
Sample Output 1
* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *
Sample Input 2
4
Sample Output 2
* * * * * * * 
 * * * * * * 
  * *   * * 
   *     *

1
Expert's answer
2021-08-06T15:32:29-0400
N = int(input())
print('* ' * (2 * N - 1))
for i in range(1, N):
    print(' ' * i, end='')
    print('* ' * (N - i), end='')
    print('  ' * (i - 1), end='')
    print('* ' * (N - i), end='')
    print()

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