Firstly you should create a dict
object to map the word with it's replacement. For example:
my_replacement_dict = {
"/": "and",
"&": "", # Empty string to remove the word
"\90": "",
"\"": ""
}
Then iterate over your list and replace
the words based on above dict to get the desired list:
my_list = [['hi / hello world &'], ['hi / hello world'], ['it\90s the world'], ['hello world'], ['hello "world"']]
new_list = []
for sub_list in my_list:
# Fetch string at `0`th index of nested list
my_str = sub_list[0]
# iterate to get `key`, `value` from replacement dict
for key, value in my_replacement_dict.items():
# replace `key` with `value` in the string
my_str = my_str.replace(key, value)
new_list.append([my_str]) # `[..]` to add string within the `list`
Final content of new_list
will be:
>>> new_list
[['hi and hello world '], ['hi and hello world'], ['its the world'], ['hello world'], ['hello world']]