I'm saving a few integer values into a variable from a for loop and each value gets saved into a new line.
Ex: print(line)
1
2
3
4
How to count the number of values within the variable line
(like it's 4 in this case). I tried with len()
, count()
, but it's not working.
Sample code:
fl = open('onlyfri.txt', 'r')
lines=fl.readlines()
lines = [x.strip() for x in lines]
for row in lines:
if row.find("-01-") != -1:
print(str(lines.index(row)))
fl.close