pythonで菱形を印刷する

4861 ワード

タイトル:下記の図案(菱形)を印刷する:
'''
        *

      * * *

    * * * * *

  * * * * * * *

* * * * * * * * *

  * * * * * * *

    * * * * *

      * * *

        *
'''
num = 1
while num <= 18:
    if num in list(range(1,18,2)):
        if num >= 11:
            col = 1
            while col <= (18-num):
                if col == 1:
                    print(" " * (num - 9), end='')
                print('*', end=' ')
                col += 1
            print('
'
) num += 1 else: col = 1 while col <= num: if col == 1: print(" "*(9 - num), end='') print('*', end=' ') col += 1 print('
'
) num += 1 else: continue num += 1