Answer to Question #237992 in Python for balu

Question #237992

Given

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

*

* *

* * *

* * * *

*

* *

* * *

* * * *


how can i print double patterns


1
Expert's answer
2021-09-16T06:09:19-0400
N = int(input("Enter the number: "))  
def triangle(n):
    # outer loop to handle number of rows  
    for i in range(0, n):  
        # inner loop to handle number of columns  
        # values is changing according to outer loop  
            for j in range(0, i + 1):  
                # printing stars  
                print("* ", end="")       
    
            # ending line after each row  
            print() 


#printing first triangle
triangle(N)


#printing second triangle
triangle(N)

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