-1

I have a list like this. a = ['\n', 'a', 'b', '\n', 'c', '\n'] As far as I know, the remove, pop, delete method only removes one by one. If I want to remove all'\n' from this list, the only way to do this is to use remove via a for or a while loop using remove method? Or is there a specific method?

AuccKhan
  • 1
  • 2

1 Answers1

0

How about:

a = ['\n', 'a', 'b', '\n', 'c', '\n']
list(filter(('\n').__ne__, a))
Raymond Reddington
  • 1,709
  • 1
  • 13
  • 21