Last active
July 26, 2020 06:25
-
-
Save opethe1st/41ee02d75233447e460b566932d4f111 to your computer and use it in GitHub Desktop.
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
import re | |
def solution(formatString, replacements): | |
formatString = re.sub(r'([^{]){(\d+)}}', r'\g<1>{\g<2>}}}', formatString) | |
formatString = re.sub(r'{{(\d+)}([^}])', r'{{\g<1>}}\g<2>', formatString) | |
try: | |
return formatString.format(*replacements) | |
except ValueError: | |
return '' | |
if __name__ == '__main__': | |
print(solution("A {{{0}} {2}} with {0} {1}.", ["fun", "activities", "party"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment