I’m having trouble with the function below. It seems to split the file fine but then only returns it as one element
Function:
def splitRoute():
route = []
for line in open("route.txt","r").readlines():
line = line.replace("\r","")
line = line.replace("\n","")
line = string.split(line, '>')
route.append(line)
return route
Output:
[['B', 'F']]
route.txt contents:
B>F
Is it only returning one element because there is only one line in the file?
I have another function that splits another file into a 7×7 list that works fine but is that only reaching all seven elements across because it has 7 lines?
Why are you replacing newlines? Just split the string: