Frage im Vorstellungsgespräch bei Microsoft

Coding question: replace a char in a string with another string.

Antworten zu Vorstellungsgespräch

Anonym

2. Okt. 2017

# Python Code def replaceCharacter(s, characterToBeReplaced, replacement): retVal = "" for i in s: if i == characterToBeReplaced: retVal += replacement else: retVal += i return retVal print replaceCharacter("HowIsaPresidentYourFrat", "a", "SAMMY")

Anonym

14. Aug. 2018

def replaceChar(s, ch, replacement): print(s.replace(ch, replacement))