I'm trying to make a basic text adventure game as shown below:
import time
print ("Hello and welcome to Prison Break")
print()
print("Press S to start")
while True:
choice = input("> ")
if choice == 'S'or's' :
print("Paddy Games presents...")
time.sleep (2)
print("Prison Break!")
time.sleep(1)
print("Before we begin, lets find out a bit about how you got
stuck in this prison in the first place!")
time.sleep(2.5)
print("When you are finished reading, type finished")
file = open("Prison Break Backstory.txt","r")
file_contents = file.read()
print (file_contents)
print()
The problem is that i get this when I go to run it: 'FileNotFoundError: [Errno 2] No such file or directory' I have checked that i have written the files name correctly, it is definitely there
Now I am aware that there are already solutions for this on the site using the exact, or absolute, path. However, I will be working on this at home on my raspberry pi 3 and also on my schools computers. The file will not be in the same place when i distribute the code. So in conclusion I need a solution that will make the file locatable on all computers regardless of where it is as long as it is there.
Sorry if this is a stupid question, I am still learning python and haven't perfected it yet. Thank you in advance for any replies!