import csv
def readLevel(filename,listname):
listname=[]
with open(filename, "r") as element:
csv_reader = csv.reader(element)
listname = list(csv_reader)
readLevel('level001.csv','LEVEL_001')
readLevel('level002.csv','LEVEL_002')
print(LEVEL_001)
print(LEVEL_002)
Error: name 'LEVEL_001' is not defined
I'm trying to create a function that receives a filename + listname and thus reads the data from a file (filename) and put it in a list (listname). A list is created but not with the correct name. Is there a correct way to do this ?