Please Login in order to post a comment
import os, sys, re text = sys.stdin.read() pattern = r"(?<=\s)(&{2}|[|]{2})(?=\s)" def modified_match(match_object): if match_object.group() == '&&': return 'and' else: return 'or' text = re.sub(pattern, modified_match, text) print(os.linesep.join(text.splitlines()[1:])) #removes the line count at line n°1
import re n = int(input()) pattern = r'(?<= )(&{2}|\|{2})(?= )' func = lambda x: 'and' if x.group() == '&&' else 'or' for _ in range(n): print(re.sub(pattern, func, input()))
import re n = int(input()) for _ in range(n): line = input() line = re.sub(r'(?<= )&&(?= )', 'and', line) line = re.sub(r'(?<= )\|\|(?= )', 'or', line) print(line)
import re n = int(input()) text = [input() for x in range(n)] pattern1 = re.compile(r'(?<= )&&(?= )') pattern2 = re.compile(r'(?<= )\|\|(?= )') for x in text: x = (re.sub(pattern1, "and", x)) x = (re.sub(pattern2, "or", x)) print(x)
import re for _ in range(int(input())): print(re.sub(r'(?<= )&&(?= )', 'and', re.sub(r'(?<= )\|\|(?= )', 'or', input())))
Seems like cookies are disabled on this browser, please enable them to open this website
Please Login in order to post a comment