"Replace within the fragment: Given a string. Replace every occurrence of the letter h by the letter H, except for the first and the last ones. " - Snakify python coding question
CODING QUESTION
Given a string. Replace every occurrence of the letter h
by the letter H
, except for the first and the last ones.
SOLUTION
s=str(input())print(s[:s.find("h")+1],s[s.find("h")+1:s.rfind("h")].replace('h','H'),s[s.rfind("h"):],sep="")
Input : In the hole in the ground there lived a hobbit
Output : In the Hole in tHe ground tHere lived a hobbit