Yes, it fine, Better you can use regular expressions Match headers with optional content following
headerpattern = r"\*\*(H\d): (.*?)\*\*"
headers = re.findall(header_pattern, test)