I’m fairly new to Python..
I was wondering how do i remove the whitespace that comes right before the output..
height = input("Please enter the tree height : ")
height1 = height
trunk = height/3
spacevar = str(" ")
for i in range(0,height):
print spacevar*(height)+"*"*(((i+1)*2)-1)
height = height-1
for p in range (0,trunk):
print spacevar*height1+"*"
the output is
Please enter the tree height : 5
*
***
*****
*******
=*********
*
The text slot marked with = is the “whitespace” i need to remove..
Thanks guys !
I hope I got what you mean here:
I just replaces the (height) and height1 operands to -1. Seems to have done the trick for me in the example. If this is not what you meant please just let me know.