In this HackerRank Regex Substitution problem solution, 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.

HackerRank Regex Substitution in python problem solution

HackerRank Regex Substitution in python problem solution

import re

N = int(input())
s = '\n'.join([str(input()) for i in range(N)])
for i in range(2):
    s = re.sub(' \&{2} ', ' and ', s)
    s = re.sub(' \|{2} ', ' or ', s)
print(s)