Due 12/30 at 11:59pm
A Choose Your Own Adventure (CYOA) story lets the reader make choices that change what happens next. In this project, you will write a program that runs a story of your own design. Pick any topic you like.
Your program must meet the following specifications:
text: the text shown to the reader on this pageoptions: a list of dictionaries, each with:
text: the text of the choice shown to the readerpage: the page number to go to next, or None if this choice ends the storyHere is a short example with 2 pages (yours must have at least 8):
story = {
1: {
"text": "You wake up and hear a knock at the door.",
"options": [
{"text": "Open the door", "page": 2},
{"text": "Ignore it", "page": 2}
]
},
2: {
"text": "The knocking stops. THE END",
"options": [
{"text": "Quit", "page": None}
]
}
}
def show_page(page):
# TODO: print page["text"], then print each option with a number, e.g. "1) Open the door"
pass
story = {
# fill in your story here
}
current_page = 1
while current_page is not None:
page = story[current_page]
show_page(page)
choice = input("\n>> ")
# TODO: check if choice is a valid option number; if valid, set current_page to that
# option's "page", otherwise print a warning and show the same page again
You wake up and hear a knock at the door.
1) Open the door
2) Ignore it
>> 3
Invalid choice "3"
You wake up and hear a knock at the door.
1) Open the door
2) Ignore it
>> 2
The knocking stops. THE END
1) Quit
>> 1