HackerRank Python String Mutations Problem Solutions

HackerRank Python String Mutations Problem Solutions

Instructor-svgAl-Mamun Sarkar
Mar 23 , 2020

HackerRank Python String Mutations Problem Solutions.

Code:


def mutate_string(string, position, character):
    str_list = list(string)
    str_list[position] = character
    return ''.join(str_list)


if __name__ == '__main__':
    s = input()
    i, c = input().split()
    s_new = mutate_string(s, int(i), c)
    print(s_new)

Input

abracadabra
5 k

Output

abrackdabra
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram