Actually I was working on a regex problem whose task is to take a substring (||, &&) and replaces it with another substring (or, and) and I wrote code for it but that's not working well
question = x&& &&& && && x || | ||\|| x
Expected output = x&& &&& and and x or | ||\|| x
Here is the code I wrote
import re
for i in range(int(input())):
print(re.sub(r'\s[&]{2}\s', ' and ', re.sub(r"\s[\|]{2}\s", " or ", input())))
My output = x&& &&& and && x or | ||\|| x