Skip to content

Instantly share code, notes, and snippets.

@horvatha
Last active December 19, 2020 19:15
Show Gist options
  • Save horvatha/7ed7c994f1bb7401f00b87fd2ab1615b to your computer and use it in GitHub Desktop.
Save horvatha/7ed7c994f1bb7401f00b87fd2ab1615b to your computer and use it in GitHub Desktop.
with open("naplo.txt") as f:
lines = f.readlines()
hi = []
for l in lines:
if l[0] != '#':
hi.append(l)
print(f'A naplóban {len(hi)}')
# Ugyanezt csinálja, list comprehension néven kereshetsz rá
# Van dict és set comprehension is. Sokszor kényelmesebb és tömörebb mint a fenti.
hi2 = [l for l in lines if l[0] != '#']
print(f'A naplóban {len(hi2)}...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment