Python数字金字塔代码
代码如下:
import random
a=int(input("请输入一个数字"))
for i in range(1,a+1,1):
for j in range(1,a+1-i,1):
print(' ',end=' ')
for j in range(i,0,-1):
if j<10:
print(' %s ' % j, end='')
else:
print('%s ' % j, end='')
for j in range(2,i+1,1):
if j<10:
print(' %s ' % j, end='')
else:
print('%s ' % j, end='')
print("")