How to replace string in list of strings with Python

1 Answer

0 votes
lst = ['java', 'python', 'php', 'java', 'nodejs'] 
  
lst = [sub.replace('php', 'WORD') for sub in lst] 

print(lst)
      


        
'''
run:
 
['java', 'python', 'WORD', 'java', 'nodejs']
        
'''

 



answered May 1, 2020 by avibootz

Related questions

1 answer 158 views
...