Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
"Non Empty Lines" solution in Uncategorized category for Non Empty Lines by Mateusz_Wryszcz
def non_empty_lines(text: str) -> int:
lines = text.split("\n")
count = 0
for line in lines:
if line.strip():
count += 1
return count
print("Example:")
print(non_empty_lines("one simple line\n"))
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!")
Dec. 21, 2022