N as input. Write a program to print the pattern of 2*N - 1 rows using an asterisk(*) as shown below.Note: There is a space after each asterisk * character.Input
The first line of input is an integer
N.Explanation
In the given example,
N = 4.So, the output should be
* * * *
* *
* *
* * * *
*
*
* * * *
Sample Input 1
4
Sample Output 1
* * * *
* *
* *
* * * *
*
*
* * * *
1
Expert's answer
2021-07-27T07:43:27-0400
N=int(input())
rows=2*N - 1
for r in range(0,rows):
for c in range(0,N):
if r>0 and r<rows-1 and r!=N-1:
if c>0 and c<N-1:
print(" ",end=" ")
else:
if r>=N and r<rows-1 andc==0:
print(" ",end=" ")
else:
print("* ",end=" ")
else:
print("* ",end=" ")
print("\n")
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments