program to remove a newline in Python code example
Example 1: remove n from string python
a_string = a_string.rstrip("\n")
Example 2: Python program to remove newline characters from a file
with open('file1.txt','r+') as f:
line = f.readlines()
print(line)
[print(l.strip()) for l in line]