Python output on a separate lines -


i have simple question python. wrote working script when execute it, gives me answer in 1 line, string. looking answer on 2 separate lines. here code: python code

def test():     fh=open('xxxxxxx.txt', 'r')     fo=open('output.txt', 'a')     line in fh:             line=line.strip()             if(line.startswith('total sequences')):                  fo.write(line)     fh.close() fh2=open('xxxxxxx.txt', 'r') fo2=open('output.txt', 'a') line in fh2:             line=line.strip()             if(line.startswith('sequence length')):                  fo2.write(line) fh2.close() print(test()) 

you removing newline characters "\n" each line in file statement:-

line=line.strip()

just remove , should work correctly.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -