Objective
Create a Python program with a generator that filters the lines of a text, processing them one at a time.
Instructions
- Read an integer
nand thennlines of text, which are stored in a list. - Define
def without_comments(lines), which goes through the lines and yields only those that do not start with#. - Show each yielded line with its sequence number starting at 1, with the format
N: line(useenumerate(..., 1)). - At the end show
Total: K, with the number of lines that were not comments.
4
# configuración
x = 1
# otra nota
y = 2
1: x = 1
2: y = 2
Total: 2
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise