You can try something like this:
eq_txt = ['or', [{'fact': 'name', 'operator': 'equals', 'criteria': 'Network'}]]
gt_txt = [[{k: ('greater' if v == 'equals' else v) for k, v in d.items()} if isinstance(d, dict) else d for d in e] if isinstance(e, list) else e for e in eq_txt]
print(gt_txt)
# Output: ['or', [{'fact': 'name', 'operator': 'greater', 'criteria': 'Network'}]]
Weird? Let's break it down:
gt_txt = [A1 if isinstance(e, list) else e for e in eq_txt]
A1 := [A2 if isinstance(d, dict) else d for d in e]
A2 := {k: A3 for k, v in d.items()}
A3 := 'greater' if v == 'equals' else v
So, for each element in the original list, check if this element a list. If it is (let's call it e), return A1. If it's not, return the element itself.
If e is a list, for each element in e, check if this element is a dict. If it is (let's call it d), return A2. If it's not, return the element itself.
If d is a dict, for each key-value pair in d, return the key mapped to "greater" if the previous value was "equal" else to the previous value.
If you want to replace every occurence of "greater" inside the original list, you can use the json module only if your original list contains types such as strings, numbers, lists and dicts:
import json
eq_txt = ['or', [{'fact': 'name', 'operator': 'equals', 'criteria': 'Network'}]]
gt_txt = json.loads(json.dumps(eq_txt).replace('equals', 'greater'))
print(gt_txt)
# Output: ['or', [{'fact': 'name', 'operator': 'greater', 'criteria': 'Network'}]]
if txt[1][0]['operator'] == 'equals':/txt[1][0]['operator'] = 'greater'.