格式如图:
代码实现:
def triangle(row): for i in range(1,row+1): for x in range(i): print('*',end='') print() for i in range(1,row+1): for x in range(row-i): print(' ', end='') for x in range(i): print('*', end='') print() for i in range(1, row + 1): a=row-i for x in range(a): print(' ',end='') for x in range(2*i-1): print('*', end='') print() row = int(input()) triangle(row)
标签:end,python,打印,range,print,triangle,三角形,row From: https://www.cnblogs.com/cs0513/p/18067024