Closed villares closed 5 months ago
How about this:
with open('atividades.txt', 'r') as arquivo:
atividades = (atividade.strip() for atividade in arquivo)
novas_atividades = [ atividade for atividade in atividades if atividade != '' ]
from collections import Counter
and the rest stays as you wrote it…? (yes, I am a fan of generators and list comprehensions)
Yeah! Thanks, that could be nice. I think at this point the students might have seen my page about comprehensions! Maybe I should add the .strip() to the filter condition too, otherwise some space filled lines might get through.
acrescentei na página sobre dicionários!
https://docs.python.org/3/library/collections.html#collections.Counter