def getCandidates(f):
try:
candidates = []
flist = open(f,"r")
for line in flist:
line = line.strip()
if (line==""):
continue
candidates.append(line)
return candidates
except IOError:
print("Filename not found")
return candidates
Need to remove any non alphanumeric characters coming from a text file into a list of strings, should I use a another loop or is there a way to implement it into my existing code.
Cheers.