# Method: Load levelsList using the data in levelsFile
def readLevelsFromFile(self):
try:
# Set levelsList to an empty list
# Open the file
# Use a loop to read through the file line by line
# If the last two characters in the line is "\n", remove them
# Append the line to levelsList
# Close the file
except:
return
def readLevelsFromFile(file):
try:
levelslist = []
f = open(file, 'r')
lines = f.readlines()
for i in lines:
if i[-1] == '/n' and i[-2] == '/n':
i.replace(i[-1],'')
i.replace(i[-2],'')
levelslist.append(i)
f.close
except OSError as e:
return e.errno
Comments
Leave a comment