Sort by

recency

|

300 Discussions

|

  • + 0 comments
    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
    
  • + 0 comments
    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()))
    
  • + 0 comments
    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)
    
  • + 0 comments
    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)
    
  • + 0 comments
    import re
    for _ in range(int(input())):
        print(re.sub(r'(?<= )&&(?= )', 'and', re.sub(r'(?<= )\|\|(?= )', 'or', input())))