Answer to Question #222374 in Python for srikanth

Question #222374
Solid Right Angled Triangle - 2

Given an integer number 

N as input. Write a program to print the double triangular pattern of N lines using an asterisk(*) character as shown below.

Note: There is a space after each asterisk * character.

Input

The first line of input will contain a positive integer.

Explanation

Given 

N = 4, there should be 2 triangular patterns with 4 lines each. So, the output should be

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

1
Expert's answer
2021-08-06T04:24:57-0400
N = int(input())

pattern = []
for i in range(1, N + 1):
    pattern.append(' '.join(['*' for _ in range(i)]))
print('\n'.join(pattern))
print('\n'.join(pattern))

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