We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def mutate_string(string, position, character):
string = ",".join(string)
li = string.split(",")
for i in range(len(li)):
if i == position:
li[i]=character
st = "".join(li)
return st
Python Code:
def mutate_string(string, position, character):
def mutate_string(string, position, character): string = ",".join(string) li = string.split(",") for i in range(len(li)): if i == position: li[i]=character st = "".join(li) return st
def mutate_string(string, position, character): if len(string)>position: new_string=string[:position]+character+string[position+1:] return( new_string) else: new_string =string
def mutate_string(string, position, character): s=[i for i in string] s[position] = character s="".join(s) return s