Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completed Task/03 #20

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion task-01/completed.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Those who have completed this task:

hsnee
15 changes: 12 additions & 3 deletions task-03/get_top_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ def extract_data_lines(filename, start_text, end_text):
open `filename`, and yield the lines between
the line that contains `start_text` and the line that contains `end_text`
"""
# fill in code as needed
turn_on = False
with open(filename) as fh:
for line in fh:
# fill in code as needed
# use `yield line` to return desired lines but keep the function going
if turn_on=='done': break

if end_text in line:
turn_on = 'done'
if include_end: yield line

if turn_on: yield line

if start_text in line:
turn_on = True
if include_start: yield line


if __name__ == '__main__':
filename = 'top5names.html'
Expand Down