Printing Simple Diamond Pattern in Python

后端 未结 15 2604
执笔经年
执笔经年 2020-12-19 23:14

I would like to print the following pattern in Python 3.5 (I\'m new to coding):

    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *
         


        
15条回答
  •  不知归路
    2020-12-19 23:17

    print('This is in python 3.7')
    h=eval(input('Enter the diagonal?'))
    j=1
    for i in range(h,h//2,-1):
        print(' '*(i-(h//2)-1),'*'*j)
        j+=2
    j-=4
    for i in range(1,(h//2)+1,1):
        print(' '*i,'*'*(j))
        j-=2
    

提交回复
热议问题