my_list=['A0_123','BD_SEI','SW_TH']
I need to replace the '_' to ' ' .
Expected output: my_list=['A0 123','BD SEI','SW TH'] Can some one help me?
CodePudding user response:
As pointed out by @python_user, you can iterate through every element in your list using a list comprehension and using replace()
:
new_list = [i.replace('_', ' ') for i in my_list]
Returns your expected output
['A0 123', 'BD SEI', 'SW TH']