打印等腰三角形

   *
***
*****
*******
for i in range(1,5):
    for k in range(0,5-i):
        print(" ",end='')
    for j in range(1,2*i):
        print("*",end='')
    print()
   *
* *
* *
*******
for i in range(1,5):
    for k in range(5-i):
        print(' ',end='')
    for j in range(1,2*i):
        if i == 1 or i == 4 or j == 1 or j == 2*i - 1:
            print('*',end='')
        else:
            print(' ',end='')
    print()

 

posted @ 2019-05-08 10:44  Python及时行乐  阅读(1471)  评论(0编辑  收藏  举报