Uso del método reemplazar () para eliminar nuevas líneas de una cadena

# Python code to remove newline character from string using replace() method

text = "A regular \n expression is a sequence \n of characters\n that specifies a search\n pattern. "
print(text.replace('\n', ''))

my_list = ["Python\n", "is\n", "Fun\n"]
new_list = []

print("Original List: ", my_list)

for i in my_list:
    new_list.append(i.replace("\n", ""))
print("After removal of new line ", new_list)
Gorgeous Gazelle