Reputation: 173
So I am writing a function that takes in a string input (ex: abcdefg
) and a shorter portion of that input (ex: cde
) and searches for it within the first longer string.
How do I make it so that only that second portion is capitalized in the first string?
Ex:
Upvotes: 5
Views: 6916
Reputation: 336078
>>> a = "abcdefg"
>>> b = "cde"
>>> c = b.upper()
>>> a.replace(b,c)
'abCDEfg'
Upvotes: 6