Now it’s time for you to begin coding your text-based adventure game!Starting at the top, convert each line of your pseudocode from your Coding Log into a line of Python code.Make sure to use the correct syntax and indentation. If you decide to challenge yourself and use functions, be sure to include the correct function calls.Your code should include at least two loops—one while loop and one for loop.Run and test your code in parts as you go. Follow the iterative process of coding and revising. It may be helpful to apply this process to each part of your game (Intro, Part 1, Part 2, and Part 3).Make the following improvements to your game:If the user types in a slightly different word than you expect, you don’t want your game to crash! Use lists to gain a better understanding of the input that users give. Refer back to Unit 1 for more information on lists. Here is an example:

```

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.")
```