Good day! Please tell me how to implement this: It is necessary to find certain words in the text of the file and replace them with other words, the words that need to be found are contained in the list of old_data, the words with which need to be replaced in new_data
old_data = ['qwe', '123', 'asd'] new_data = ['qwe', '123', 'asd'] For a single case when we have one word and we need to change it into one word, I wrote the f-th
def Params(self, old_data, new_data, file): file = open(mapfile, 'r') text = file.read() file.close() file = open(mapfile, 'w') file.write(text.replace(old_data, new_data)) file.close() Everything works, but I don’t understand how to make it take two lists and work with them, I tried to do it with a cycle, but it incorrectly replaces me, in the sense that it doesn’t replace all the elements or then appends extra ones. In general, I ask for help. Thank you in advance!