I have a list of strings in Python, containing alphabets and operators as follows:
['a', '+', 'b', 'd', '+', 'e', 'g', '*', 'h', '/', '-', '/'].
I am trying to use Python to rename the first '+' as potentially '+1' (where the '1' next to '+' could be a subscript) and the second '+' as '+2' to distinguish between the two '+' operators. And so on for the other operators as well. Also, for similar other bigger examples containing multiple '+', '-', '*', '/', '<', '>', etc.
For example, in the above list of strings, the modification would result to the desired output I wish to achieve:
['a', '+1', 'b', 'd', '+2', 'e', 'g', '*1', 'h', '/1', '-1', '/2'].
I was trying to use a for loop to find each operator and replace it by the numbers, but haven't been successful. Your help would be highly appreciated.