We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defmutate_string(string,position,character):# Slice the string and join it back (quicker but harder to visualize)'''Thestringisslicedintotwoparts:string[:position]:fromthestartofthestringupto(butnotincluding)thepositionindex.string[position+1:]:fromthecharacterrightafterthepositionindexuntiltheendofthestring.Weprocesstoputthecharacterbetweentheparts'''s_new=string[:position]+character+string[position+1:]returns_newif__name__=='__main__':s=input()i,c=input().split()s_new=mutate_string(s,int(i),c)print(s_new)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mutations
You are viewing a single comment's thread. Return to all comments →
Solution #2