Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Another mission solved with partition() solution in Clear category for Non Empty Lines by adamspj
def non_empty_lines(text: str) -> int:
non_empty = 0
while text:
current_line, _, text = text.partition('\n')
if current_line.strip(): # A line consisting only of whitespace will be reduced to '' and return False
non_empty += 1
return non_empty
March 17, 2024
Comments: