while True: num = int(input("Enter a number: ")) for i in range(1, num + 1): print(i, end=" ") if input("\nPlay again? (y/n): ") == "n": break print("Thanks for playing!")