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

Problem solution in Python 2 programming.

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 programming.

string = input()
line = input().split()
i, c = int(line[0]), line[1]
print(string[:i] + c + string[i+1:])

Problem solution in PyPy programming.

# 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)

Problem solution in PyPy3 programming.

#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