I have a file of images and I want the folder to have a random file selected and that image to be displayed. This is the code I have so far:
dir = path.dirname(__file__)
examQ_dir = path.join(dir, 'Exam Questions')
question = choice(path.join(examQ_dir))
image_surface = pg.display.set_mode((850, 500))
image = pg.image.load(question)
And the error I get is as follows:
Traceback (most recent call last):
File "D:/A level Comp Sci/Platformer Game in Development Stages/Question.py", line 13, in <module>
image = pg.image.load(question)
pygame.error: Couldn't open E
And everytime I run it, the last letter of the error is slightly different sometimes it will say
pygame.error: Couldn't open i
And other times there's nothing there at all. I think there's something wrong with my logic of setting this up but I can't work out what. I'm using the PyCharm IDE.