Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Non Empty Lines by Pavellver
def non_empty_lines(text: str) -> int:
counter = 0
new_text = text.strip().split('\n')
for i in new_text:
if i.strip():
counter += 1
return counter
print("Example:")
print(non_empty_lines("one simple line\n"))
# These "asserts" are used for self-checking
assert non_empty_lines("one simple line\n") == 1
assert non_empty_lines("") == 0
assert non_empty_lines("\nonly one line\n ") == 1
assert (
non_empty_lines(
"\nLorem ipsum dolor sit amet,\n\nconsectetur adipiscing elit\nNam odio nisi, aliquam\n "
)
== 3
)
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 26, 2023
Comments: