Lab cycle5
Exercise 5:
Use a for loop to print a triangle
like the one below.
Allow the user to specify
how high the triangle should be.
*
**
***
****
Source Code:
n = int(input("Enter height of triangle: "))
for i in range(n):
for j in range(i+1):
print("*",end="")
print()
(or)
for i in range(1,5):
print(i*"*")
RESULT:
Enter height of triangle: 4
*
**
***
****
Comments
Post a Comment