with open("result.txt") as f:
# find line starting with Residue XXX
next(line for line in f if not line.startswith("Residue XXX"))
# get next three lines into a list (empty string for nonexistent lines)
results = [next(f, "").rstrip() for line in range(3)]
行をリストResidue XXX
の最初の項目として保持する場合:results
with open("result.txt") as f:
# find line starting with Residue XXX
results = [next(line for line in f if not line.startswith("Residue XXX").rstrip()]
# add next three lines to the list (empty string for nonexistent lines)
results.extend(next(f, "").rstrip() for line in range(3))