I know it might sounds dumb to you but im learning Python right now by following course on the internet and they ask us to create a kind of labyrinth.
They give a "base code", but when I try to run it, it says FileNotFoundError: [Errno 2] No such file or directory: 'cartes', the error is in os.listdir(cards).
I would like the code to list the contents of a local directory named cartes
but am unable to do so because I receive the FileNotFoundError.
This is the code that I'm struggling with:
# -*-coding:Utf-8 -*
"""This file contains the main code of the game.
Run him with Python to start the game.
"""
import os
from map import Map
# We load the existing maps
maps = []
for file_name in os.listdir("maps"):
if file_name.endswith(".txt"):
path = os.path.join("maps", nom_fichier)
map_name = file_name[:-3].lower()
with open(path, "r") as file:
content = file.read()
# Map creation, to complete
# We display the existing maps
print("Existing labyrinths :")
for i, map in enumerate(maps):
print(" {} - {}".format(i + 1, map.nom))
# If there is a saved game, we display it, to complete
# ... Complete the program ...