We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Regex Substitution
Regex Substitution
Sort by
recency
|
303 Discussions
|
Please Login in order to post a comment
import re and_pattern = re.compile( r"(?<=[\s])[&&]{2}(?=[\s])" ) or_pattern = re.compile( r"(?<=[\s])[||]{2}(?=[\s])" )
for _ in range(int(input())): print( re.sub(and_pattern,'and', re.sub(or_pattern, 'or', input())) )
Could reduce it down, however it would make it less readable.
Sometimes fewer lines isn't better