I am trying to create a python code that will delete line break (\n) if a character (<) does not appear in that line. Currently I cannot see any effects. This is the code i wrote so far:
protein=open(r"string.txt","r+")
def main():
print(protein.readlines())
print()
rewrite()
def rewrite():
for line in protein:
if line == "<":
print (line)
if line != "<":
line.replace("\n"," ")
print(protein)
protein.close
main()
Input Example:
Name1<<
Data1
Data1
Data1
Name2<<
Data2
Data2
Data2
Expected Output Example:
Name1<<
Data1Data1Data1
Name2<<
Data2Data2Data2