📜  python代码示例中的菱形

📅  最后修改于: 2022-03-11 14:47:10.676000             🧑  作者: Mango

代码示例1
def p(n):
    for i in range(n):
        print(" "*(n-i-1),end="")
        print("* "*(i+1))
        
    for j in range(n-1, 0, -1):
        print(" "*(n-j),end="")
        print("* "*(j))

star_num = int(input("Enter a number that shows diameters of your diamond shape: "))
print(p(star_num))