Given
N = 4, there should be 2 triangular patterns with 4 lines each. So, the output should be
*
* *
* * *
* * * *
*
* *
* * *
* * * *
how can i print double patterns
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)
Comments
Leave a comment