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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -