How to remove newline character from list of strings in Python

1 Answer

0 votes
lst = ['\npython\n', 'programming\n', 'language\n'] 
  
l = [] 
for sub in lst: 
    l.append(sub.replace("\n", "")) 

lst = l

print(lst)  

         
      
'''
run:
 
['python', 'programming', 'language']
      
'''

 



answered Apr 24, 2020 by avibootz
...