name = input("What is your name? ") while True: try: Num = int(input("How many times do you want it written? ")) if Num > 0: break else: print("Please enter a positive number.") except ValueError: print("Invalid input. Please enter a number.") for i in range(Num): print(name, end=" ")