my text file contains, paragraphs something like this.
summary
A result oriented and dedicated professional with three years’ experience in Software Development
The second conditional statement here will never run, as it has an identical condition to the first one. Meaning copy will always be True
after the first instance of summary
.
if line.strip() == 'summary':
re.compile('\r\nproject*\r\n')
copy = True
elif line.strip() == "summary":
copy =False
What I'd recommend is having one statement that picks up the "summary" tags (I assume these are meant to be start/end of comment blocks) - and toggle copy
.
To toggle a boolean, you can simple set it to the inverse of itself:
a = True
a = not a
# a is now False
For example:
if line.strip() == 'summary':
copy = not copy
elif copy:
outfile.write(line)