Jun-22-2020, 10:52 PM
I want to take:
I tried:
s = '1 w 2 r 3g'And format it to:
s = '1 W 2 R 3g'Based on the concept that the first letter after any space is converted to upper including the first letter.
I tried:
s.title()but did not get good results. I then tried regex.
pattern = '\s\w|^\w' re.finditer(pattern, s)Which found all the matches but I have a problem. Now that is found the matches, how do I convert the matched letters to uppercase? Can someone help me. I tried using indexing but the interpreter gave error that no item assignment is allowed with strings. Immutable. Can someone suggest how I can solve this now that am halfway through?