HackerRank Mutations problem solution in Python – In this HackerRank Mutation problem solution in python, We have seen that lists are mutable (they can be changed), and tuples are immutable (they cannot be changed). Read a given string, change the character at a given index and then print the modified string.

HackerRank Mutations problem solution in Python 2.
S=raw_input()
i,c=map(str,raw_input().split())
i=int(i)
print S[:i] + c + S[i+1:]
Problem solution in Python 3.
string = input()
line = input().split()
i, c = int(line[0]), line[1]
print(string[:i] + c + string[i+1:])
Problem solution in PyPy.
# Enter your code here. Read input from STDIN. Print output to STDOUT
S=raw_input()
n,a=raw_input().split()
l=list(S)
l[int(n)]=a
print ''.join(l)
PyPy3 Solution.
#def mutate_string(string, position, character)
#print(input())
string=list(input())
[a,b]=(input().split())
#print ([a,b])
#print(string[int(a)])
#print(i)
#print(rep)
#string = string[:i] + str(b) + string[(i+1):]
string[int(a)]= str(b)
string="".join(string)
print (string)
#return
Next problem solution – HackerRank Find a String solution in Python