Created
March 24, 2022 21:53
-
-
Save aasmpro/4f19a4d5886064ecc9e8ba7e7f7545f7 to your computer and use it in GitHub Desktop.
Script to add parranteses in certain positions in a line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = input() | |
pairs_count = int(input()) | |
pairs = [] | |
for i in range(pairs_count): | |
pair = input().split() | |
pairs.append([int(i) for i in pair]) | |
output = [] | |
length = len(text) | |
for index in range(length+1): | |
for pair in pairs: | |
if index == pair[1]: | |
output.append(")") | |
for pair in pairs: | |
if index == pair[0]: | |
output.append("(") | |
try: | |
output.append(text[index]) | |
except Exception as e: | |
pass | |
print("".join(output)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample:
output: