while 1 :
    try:
        a = int(input())
        for i in range(1,a+1):
            print(a * '* ')
    except:
        break

加入一个while循环就可以