```
valid_inputs = ["yes", "no"]
user_input = input("Do you want to play again? ")
if user_input.lower() in valid_inputs:
# continue the game
else:
# end the game
```
Create a function for each part of your game (Intro, Part 1, Part 2, and Part 3), and call those functions in a main function. This will make your code cleaner and easier to understand. Here is an example:
```
def intro():
# code for the intro
def part1():
# code for part 1
def part2():
# code for part 2
def part3():
# code for part 3
def main():
intro()
part1()
part2()
part3()
if __name__ == "__main__":
main()
```
Add error handling to your game. For example, if the user enters a non-integer input when prompted for a number, display an error message and ask them to try again. Here is an example:
```
while True:
try:
num = int(input("Enter a number: "))
break
except ValueError:
print("Invalid input. Please enter a number.")
```