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