📜  用整数创建菱形的python代码 - Python代码示例

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

代码示例2
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))