try: while True: # Read the dimensions of the square size = int(input("Tamaño: ")) if size == 0: break if size > 0 and size <= 20: # For each line for row in range(size): # Print a line for column in range(size): print("*", end="") print() else: print("Tamaño debe estar entre 1 y 20") except ValueError: print("Tamaño inválido")