Enumerate attaches a running position even to an empty element.
for number, item in enumerate(["pen", "", "pad"], start=1):
if item.startswith("p"):
print(number, item)
# 1 pen
# 3 padAn open file is iterable too. Count physical lines while checking each one for the search term.
Implement matching_lines(path, term). Return the one-based line numbers of all lines containing the nonempty term as a case-sensitive substring. Return a line number only once even if the term appears twice on it.
# If notes.txt contains "wet\n\nnew wet trail\n":
matching_lines("notes.txt", "wet") # [1, 3]