In: Computer Science
Write a python code which prints triangle of stars using a loop ( for loop ) Remember what 5 * "*" does
The number of lines of output should be determined by the user. For example, if the user enters 3, your output should be:
*
**
***
If the user enters 6, the output should be:
*
**
***
****
*****
******
You do NOT need to check for valid input in this program. You may assume the user enters a positive integer.
n=int(input("Enter number of lines:- "))
for i in range(1, n+1):
for j in range(1, i+1):
print("*", end="")
print()
Code snippet for your help in indentation
n=int(input("Enter number of lines:- "))
for i in range(1, n+1):
for j in range(1, i+1):
print("*", end="")
print()
Output:-
Enter number of lines:- 6
*
**
***
****
*****
******
Enter number of lines:- 6
*
**
***
****
*****
******
For any query in any part of the answer you can comment below.
If you like the answer please give a like.
Happy to help. :)