fork(1) download
  1. #!/usr/bin/env python
  2. """Exclusive flip-flop operator."""
  3. import fileinput
  4.  
  5. START, END = 'Part 1', 'Part 0'
  6. inblock = False
  7. for line in fileinput.input():
  8. line = line.rstrip()
  9. if inblock:
  10. if line == END:
  11. inblock = False
  12. else:
  13. print(line)
  14. elif line == START: # not in block
  15. inblock = True
Success #stdin #stdout 0.04s 9380KB
stdin
Ненужный текст
Part 1
A1
Kh A
A4
H6
Part 0
Ненужный текст
Ненужный текст
Part 1
A1
Kh A
A4
H6
Part 0
Ненужный текст
stdout
A1
Kh A
A4
H6
A1
Kh A
A4
H6