1

I want to do more than one replacement in a single line. I am working with really complicated code that would benefit from this. I made a simple example of my problem below:

lines = ['Temp = 65   ;   Temperature = degrees Farenheit',
     'Mass = 15   ;   Mass = Pounds'
     ]
lines2 = []
a = ['Farenheit','Celsius']
b = ['Pounds','Grams']


for s in lines:
    linez = s.replace(a,b)
    lines2.insert(0,linez)

print(lines2)

I want to be able to add more replacements in the future without having to make new for loops and empty lists.

Paul
  • 107
  • 8
  • Possible duplicate of [How to replace multiple substrings of a string?](https://stackoverflow.com/questions/6116978/how-to-replace-multiple-substrings-of-a-string) – wizzwizz4 Aug 06 '19 at 15:31

0 Answers0