n = int(input("请输入菱形的边长:"))
for i in range(1, n+1):
print(" "*(n-i), end="")
print("* "*(i))
for i in range(n-1, 0, -1):
print(" "*(n-i), end="")
print("* "*(i))
运行结果:
n = int(input("请输入菱形的边长:"))
for i in range(1, n+1):
print(" "*(n-i), end="")
print("* "*(i))
for i in range(n-1, 0, -1):
print(" "*(n-i), end="")
print("* "*(i))
运行结果: