- problem : 파일은 거의 1000줄에 달한다. 짝수줄에 있는 line을 가져와라
- sample dataset
Bravely bold Sir Robin rode forth from Camelot
Yes, brave Sir Robin turned about
He was not afraid to die, O brave Sir Robin
And gallantly he chickened out
He was not at all afraid to be killed in nasty ways
Bravely talking to his feet
Brave, brave, brave, brave Sir Robin
He beat a very brave retreat
- sample output
Yes, brave Sir Robin turned about
And gallantly he chickened out
Bravely talking to his feet
He beat a very brave retreat
- 풀이
f = open ('rosalind_ini5.txt', 'r')
fo = open('output.txt', 'w')
line = f.read()
line = line.split('\n')
for i in line:
if line.index(i)%2 == 1 :
fo.write(i+ '\n')
f.close()
fo.close()
반응형