题解 | #菱形图案#
菱形图案
http://www.nowcoder.com/practice/8b935f8ffe99445dbd42494febd13e45
while True:
try:
num = int(input())
a, b = 0, num # num不能变,创建两个变量
for i in range(1, num*2+2): # 实际应该输出num+1行
if i > (num + 1):
print(" " * (i - num - 1) + "* " * b) # 后num行
b -= 1
else:
print(" " * (num - a) + "* " * (a + 1)) # 前num+1行
a += 1
except:
break