Created
June 28, 2019 11:21
-
-
Save linjungz/43b00385217b268fa5051e817ca9b584 to your computer and use it in GitHub Desktop.
Remove duplicated consecutive lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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