python - Asterisk Triangle -
i'm coming background in google's app inventor. i'm taking online class.
task: make triangle out of asterisks nested while loop. triangle has base of 19 asterisks , height of 10 asterisks.
here's am.
num = 1 while num <= 19: print '*' num = num * '*' + 2 print num
you can use 'center'-method string-objects:
width = 19 num in range(1, width + 1, 2): print(('*' * num).center(width)) * *** ***** ******* ********* *********** ************* *************** ***************** *******************
Comments
Post a Comment