-
Notifications
You must be signed in to change notification settings - Fork 5
/
RegexSubstitution.py
36 lines (33 loc) · 995 Bytes
/
RegexSubstitution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import re
for i in range(int(input())):
s = re.sub(r' &&(?= )', ' and', input())
print(re.sub(r' \|\|(?= )', ' or', s))
# Task
# You are given a text of N lines. The text contains && and || symbols.
# Your task is to modify those symbols to the following:
# && → and
# || → or
# Both && and || should have a space " " on both sides.
# Sample Input
# 11
# a = 1;
# b = input();
# if a + b > 0 && a - b < 0:
# start()
# elif a*b > 10 || a/b < 1:
# stop()
# print set(list(a)) | set(list(b))
# #Note do not change &&& or ||| or & or |
# #Only change those '&&' which have space on both sides.
# #Only change those '|| which have space on both sides.
# Sample Output
# a = 1;
# b = input();
# if a + b > 0 and a - b < 0:
# start()
# elif a*b > 10 or a/b < 1:
# stop()
# print set(list(a)) | set(list(b))
# #Note do not change &&& or ||| or & or |
# #Only change those '&&' which have space on both sides.
# #Only change those '|| which have space on both sides.