Hi, I am trying to simplify a list of fruits in one file, by generalizing them to "fruit". However, I can only using regular tuples and re, replace one by one. Here I would need to replace 4 different words with one, as the example shows below. But it doesn't work. Any ideas?
Thanks
Thanks
fruit = ("Apple", "Orange", "Banana", "Mandarin") fruit_trans = {} fruit_trans = [("fruit")] trans = string.maketrans("Apple", "Orange", "Banana", "Mandarin") my_string = my_string.translate(trans)