Minimal example:
Code
s = "A or B and C"
d = {"A": "1", "B": "0", "C": "0"}
for key, value in d.items():
s = s.replace(key, value)
print(s)
Output
1 or 0 and 0
This code produces the desired output, i do however feel like there is a clever one-liner that can replace my loop.