-3

I have a list and every element of list consists of an escape sequence "\n" .. How to remove these "\n" from the elements?

2

1 Answer 1

4

Like this:

lst = ['\n', 'hello\n']
new_lst = [entry.replace('\n','') for entry in lst]
print(new_lst) #['', 'hello']
Sign up to request clarification or add additional context in comments.

2 Comments

its not working.. Is any library or built-in function available for this ??
Well, you would need Python to run it. Apart from yet, nothing is needed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.