You are viewing a single comment's thread. Return to all comments →
import re def substitute(*pattern, **replace): for line in range(int(input())): b = input() pattern1 = (r"(?<=\s)&&(?=\s)") pattern2 = (r"(?<=\s)\|\|(?=\s)") replace1 = ("and") replace2 = ("or") final = (re.sub(pattern1, replace1, re.sub(pattern2, replace2, b))) print(final) substitute((r"(?<=\s)&&(?=\s)"), (r"(?<=\s)\|\|(?=\s)"), ("and"), ("or"))
Seems like cookies are disabled on this browser, please enable them to open this website
Regex Substitution
You are viewing a single comment's thread. Return to all comments →