Oct-26-2022, 02:40 PM
You can loop direclty over the file object,and
Try to use
Then it can be done like this.
range()
is not nessesary.Try to use
with open
then no need to close file obejct,also using f-sting make it nicer.Then it can be done like this.
with open('list_fable.txt') as fp,open('list_out.html', 'w') as fp_out: for line in fp: fp_out.write(f'<title>{line.strip()}</title>\n')list_out.html:
Output:<title>Le Dépositaire infidèle</title>
<title>Les Deux Pigeons</title>
<title>Le Singe et le Léopard</title>