HackerRank- Python Mutations



Read a given string, change the character at a given index and then print the modified string.



  1. def mutate_string(string, position, character):
  2. a=list(string)
  3. a[position]= character
  4. string=''.join(a)
  5. return string
  6. if __name__ == '__main__':
  7. s = input()
  8. i, c = input().split()
  9. s_new = mutate_string(s, int(i), c)
  10. print(s_new)

download android app