First solution in Creative category for Non Empty Lines by Guest_5a80b5eb
This is a pointless class, but trying to use 'with'
for something other than managing external resources
since CheckiO missions don't seem to use external data.
Has anyone found a use for 'with' in CheckiO?
def __init__(self, text):
self.text = text
def __exit__(self, *exc):
return len([line for line in self.text.splitlines() if not re.fullmatch(' *', line)])
def non_empty_lines(text: str) -> int:
with line_counter(text) as lines:
April 2, 2022