Write a Python program to read a file line by line store it into an array code example
Example: Write a Python program to read a file line by line store it into an array
def conftolist(fname,mode='r+'):
with open(fname) as f:
lines = [line.strip() for line in f]
print(lines)
conftolist('file1.txt')
############
with open('file1.txt','r+') as f:
# li = list(f)
# print(li)
ls=[]
for l in f:
ls.append(l.strip())
print(ls)