Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone

Hackerrank Mutations problem solution in Python

YASH PAL, 31 July 202414 June 2025

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
Mutations solution

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

coding problems solutions Hackerrank Problems Solutions Python Solutions HackerRank

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes