Created
March 25, 2014 03:28
-
-
Save wallstop/9754717 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
markBeginGroup = "([{" | |
markEndGroup = ")]}" | |
def decodeInput(inputString): | |
output = "" | |
for character in inputString: | |
if character in markEndGroup: | |
output += " " + (inputString[inputString.rindex(markBeginGroup[markEndGroup.index(character)]) + 1 : inputString.index(character)]) | |
inputString = inputString[ : inputString.rindex(markBeginGroup[markEndGroup.index(character)])] + inputString[inputString.index(character) + 1:] | |
return " ".join(output.split()) | |
print(decodeInput("[racket for {brackets (matching) is a} computers]")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment