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.
we can do it two ways as they provided
def mutate_string(string, position, character):
string = string[:position]+character+string[position+1:]
return string
def mutate_string(string, position, character):
s_new = string[:5] + "k" + string[6:]
if name == 'main':
def mutate_string(string, position, character): strings = string l = list(strings) l[position] = character strings = ''.join(l)
if name == 'main': s = input() i, c = input().split() s_new = mutate_string(s, int(i), c) print(s_new)
we can do it two ways as they provided def mutate_string(string, position, character): string = string[:position]+character+string[position+1:] return string
and
def mutate_string(string, position, character): l=list(string); l[position]=character return ''.join(l)