I am trying to get each value from data.txt into my list. Unfortunately, I do not understand why For Loop does not work in the following case:
#(data length is 8)
example_list = []
with open("/path/data.txt") as example:
for number in range(example.readlines())):
example_list.append(example.readlines()[number])
print(example_list)
Error list index out of range appears.
When in stead of For Loop I manually insert "number" (from 0 to 8) it does work, therefore I do not understand why it does not work with for loop
Appreciate any help on that