比较喜欢用0到n的循环

while 1:
    try:
        n = int(input())
        for i in range(0,n):
            for j in range(0,n):
                if i==j or j==(n-i-1):
                    print("*",end="")
                else:
                    print(" ",end="")
            print()
            
        
    except:
        break