I have a question about inserting the contents of a text file into a list in python.
I want to put the first line of a text file in a list. In my code it runs the task but the following message appears:
[<_io.TextIOWrapper name='lista2.txt' mode='w' encoding='cp1252'>].
Below is my code:
print ("-"*50)
print ("-"*50)
itens = []
item=1
arquivo = open('lista.txt','w')
with open ('lista.txt') as f1:
conteudo = f1.read()
with open ('lista2.txt','w') as f2:
f2.write(conteudo[::-1])
itens.append(f2)
print (itens)
print ("-"*50)
print ("-"*50)