Last active
January 4, 2022 23:02
-
-
Save thautwarm/902f73fb772284a59fc2f1401a974eb3 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
from wisepy2 import wise | |
def main(filename: str): | |
"""return a pair: | |
- non-empty character count | |
- non-empty line count | |
""" | |
l = 0 | |
c = 0 | |
for line in open(filename, 'r', encoding='utf8'): | |
if not line.strip(): | |
continue | |
l += 1 | |
for ch in line: | |
if ch not in {'\n', '\r', ' ', '\t'}: | |
c += 1 | |
print(c, l) | |
if __name__ == '__main__': | |
wise(main)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment