Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Task
Read a given string, change the character at a given index and then print the modified string.
Input Format
The first line contains a string, .
The next line contains an integer , denoting the index location and a character separated by a space.
Output Format
Using any of the methods explained above, replace the character at index with character .Sample Input
abracadabra
5 k
Sample Output
abrackdabra
Mutations - Hacker Rank Solution
Using the slice : operator, we can solve this challenge.
S=raw_input() i,c=map(str,raw_input().split()) i=int(i) print S[:i] + c + S[i+1:]
string = input() line = input().split() i, c = int(line[0]), line[1] print(string[:i] + c + string[i+1:])
# 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)
#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
In our experience, we suggest you solve this Mutations Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Mutations is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution
I hope this Mutations Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
itertools.product() Hacker Rank Solution
String Validators Hacker Rank Solution
Text Alignment Hacker Rank solution