Last active
December 19, 2020 19:15
-
-
Save horvatha/7ed7c994f1bb7401f00b87fd2ab1615b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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