At the bottom is the way I usually parse a TXT file (works fine!)
My question: is there a more elegant/pythonic/best-practice way to get
[line.strip()
for line in file.readlines()
if line.strip()]
### create a sample TXT file for demo
with open('recipe.txt', 'w') as file:
file.write("""
3 oeufs
180 g de sucre
le zest de 2 citrons
""")
### parse the sample TXT file
with open('recipe.txt', 'r') as file:
lines = [line.strip()
for line in file.readlines()
if line.strip()]
# ['3 oeufs', '180 g de sucre', 'le zest de 2 citrons']