A Text adventure Part 2
If you don't yet have a portrait image .
Below is the code we have completed so far check yours against the code below and fill in any gaps
When we are creating a large program it can quickly get very difficult to find things and understand what our program is doing. To make our code easier to read we can split it up into parts and then import those parts into our main program. We do this by using the keyword import and the name of the file we want to include after it. See example below.
First I create a new file, I want to store my functions in here so I call it 'my_functionsI then create a function to print out the title of my adventure game
I now create another file main and import my functions sile into it and then call my function that prints out my title.
I have to use the name of the file the function is stored in and the name of the function when I call it.
Have a look at my code below.
I have saved it as a seperate file called question1.py
I then import it into the endo of my text adventure file see example below