Mutations

Sort by

recency

|

1078 Discussions

|

  • + 0 comments

    Python Code:

    def mutate_string(string, position, character):

    return (string[:position] + character + string[position + 1:])
    
  • + 0 comments

    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

  • + 0 comments
    def mutate_string(string, position, character):
        out = string[:position] + character + string[position+1:]
        return out
    
    if __name__ == '__main__':
        s = input()
        i, c = input().split()
        s_new = mutate_string(s, int(i), c)
        print(s_new)
    
  • + 0 comments

    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

  • + 0 comments

    def mutate_string(string, position, character): s=[i for i in string] s[position] = character s="".join(s) return s