Brian Z. answered 09/09/21
Python Software Engineer with 5+ Yrs Experience in Data Science
Hello everybody!!
I suppose that this tree should look as isosceles triangle, so the number of space character in each line starts from number 5 in the first line to 0 in the last: so the python code for that is:
for i in range(0,10):
print(' '*((10-i)//2)+'*'*(i)+str(i))
if you want a PURE tree without numbers at the end of each line, just remove str(i) from print function, so the code will be:
for i in range(0,10):
print(' '*((10-i)//2)+'*'*(i))
I hope that helps, Good Luck