Friday, November 25, 2016

Python - Drawing tree

Python - Drawing tree

Result:


without many word, now, here is the syntax:

#! usr/bin/python
def up(x):                                    #making subprogram
    i=0
    blank=" "
    star="*"
    while i<=many:
        print blank*x,star*i*2+star
        i+=1
        x-=1
while True:                                 #looping input
    many=input("Enter the tree tall: ")
    x=many
    if many>0:
        print up(many)
    else:
        print "wrong high"

This work on python 2.7, any problem just write it on comment..
Thanks for visiting

2 comments: