I am trying to print out a right-angled triangle by using a for loop, however, even though I got the shape that I intend to have, the outcome always comes with an extra line underneath the input question, I want to know how to delete it?
Here is my code:
height = int(input('Enter height: '))
for i in range(height 1):
print(i * '*')
and the output is:
Enter height: 6
*
**
***
****
*****
******
What I want to have:
Enter height: 6
*
**
***
****
*****
******
CodePudding user response:
Your code is printing i=0, which generates the blank line.
Try the below:
height = int(input('Enter height: '))
for i in range(1, height 1):
print(i * '*')