Gazou Shori ------------------------------------------------------- infile=open('/content/drive/MyDrive/data/Red3.txt') datalist=infile.readlines() infile.close() i=0 while i < 4: print(datalist[i], end="") i+=1 print() i=4 while i < 15+4: print(datalist[i], end="") i+=1 -------------------------------------------------------- infile=open('/content/drive/MyDrive/data/Red3.txt') datalist=infile.readlines() infile.close() n=len(datalist) outfile=open('/content/drive/MyDrive/test.txt', 'w') i=0 while i < 4: print(datalist[i], end="") outfile.write(datalist[i]) i+=1 print() i=4 while i < n: print(datalist[i], end="") outfile.write(datalist[i]) i+=1 outfile.close() ----------------------------------------------- infile=open('/content/drive/MyDrive/data/Red3.txt') datalist=infile.readlines() infile.close() n=len(datalist) outfile=open('/content/drive/MyDrive/test.txt', 'w') i=0 while i < 4: print(datalist[i], end="") outfile.write(datalist[i]) i+=1 print() i=4 while i < n: if (i-4) % 3 == 0: # color = red outfile.write('0\n') # omit red print('0\n') else: outfile.write(datalist[i]) print(datalist[i], end="") i+=1 outfile.close() -------------------------------------------------------- infile=open('/content/drive/MyDrive/data/Red3.txt') datalist=infile.readlines() infile.close() n=len(datalist) outfile=open('/content/drive/MyDrive/test.txt', 'w') i=0 while i < 4: print(datalist[i], end="") outfile.write(datalist[i]) i+=1 print() i=4 while i < n: if (i-4) % 3 != 0: # color not red outfile.write('0\n') # omit except red print('0\n', end="") else: outfile.write(datalist[i]) print(datalist[i], end="") i+=1 outfile.close()