Skip to content

Instantly share code, notes, and snippets.

@linjungz
Created June 28, 2019 11:21
Show Gist options
  • Save linjungz/43b00385217b268fa5051e817ca9b584 to your computer and use it in GitHub Desktop.
Save linjungz/43b00385217b268fa5051e817ca9b584 to your computer and use it in GitHub Desktop.
Remove duplicated consecutive lines
inf = open('input.txt', 'r')
outf = open('output.txt', 'w')
curWord = ''
for s in inf.readlines():
s = s.strip()
if curWord == '' or s != curWord :
curWord = s
outf.write(s + ' ')
outf.write('/')
outf.close()
inf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment