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