A
Alex Dempsey
Recently I tried to slice every element of a list of strings. First I tried:
f = open("export.xls", "r")
lines = f.readlines()
for line in lines:
line = line[1:-5]
line = line.split('\"\t\"')
This went without returning any errors, but nothing was sliced or
split. Next I tried:
for i in range(len(lines)):
lines = lines[1:-5]
lines = lines.split('\"\t\"')
This of course worked, but why didn't the first one work. Further why
didn't the first one return an error?
f = open("export.xls", "r")
lines = f.readlines()
for line in lines:
line = line[1:-5]
line = line.split('\"\t\"')
This went without returning any errors, but nothing was sliced or
split. Next I tried:
for i in range(len(lines)):
lines = lines[1:-5]
lines = lines.split('\"\t\"')
This of course worked, but why didn't the first one work. Further why
didn't the first one return an error?