Open jmpark0118 opened 3 years ago
import re
def modify_symbols(match):
symbol = match.group(0)
if symbol == '&&':
return 'and'
elif symbol == '||':
return 'or'
if __name__ == '__main__':
for i in range(int(input())):
print(re.sub(r'(?<= )(&&|\|\|)(?= )', modify_symbols, input()))
import re
if __name__ == '__main__':
for _ in range(int(input())):
print(re.sub(r'(?<= )(&&|\|\|)(?= )', lambda x: 'and' if x.group() == '&&' else 'or', input()))
출처 : https://www.hackerrank.com/challenges/re-sub-regex-substitution/problem