{}
CYBER CYBER CYBER CYBER CYBER
66
%OFF
Week Week Week Week Week

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
CYBER CYBER CYBER CYBER CYBER
66
%OFF
Week Week Week Week Week

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
main.py
def coolFunction(input): numberOfTimes = [] whatToRepeatArray = [] for character in input: if character.isdigit(): numberOfTimes.append(character) if character.isalpha(): whatToRepeatArray.append(character) numberOfTimesInt = "".join(numberOfTimes) whatToRepeat = "".join(whatToRepeatArray) finalStringTemporary = [] for i in range(int(numberOfTimesInt)): finalStringTemporary.append(whatToRepeat) return "".join(finalStringTemporary) def bracketChecker(input): currentBracketIndex = input.find("[") if currentBracketIndex == -1: return input, "" finalString = [] useless1, firstRun = input.split("[",1) secondRun, useless2 = firstRun.split("]",1) finalString.append(useless1) cleanedSubstring = coolFunction(secondRun) finalString.append(cleanedSubstring) return "".join(finalString), useless2 def spaceMessage(input): finalStringYes = [] uncleanBit = input while not uncleanBit == "": cleanedBit, uncleanBit = bracketChecker(uncleanBit) finalStringYes.append(cleanedBit) finalStringDone = "".join(finalStringYes) return finalStringDone print(spaceMessage("ABCD")) print(spaceMessage("AB[3CD]")) print(spaceMessage("IF[2E]LG[5O]D")) # Haha the last one was funny
Output