File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,19 @@ def convert_word(word: str) -> str:
1818 """
1919 Convert the first character to uppercase if it's lowercase
2020 """
21- if 'a' <= word [0 ] <= 'z' :
21+ if "a" <= word [0 ] <= "z" :
2222 word = chr (ord (word [0 ]) - 32 ) + word [1 :]
2323
2424 """
2525 Convert the remaining characters to lowercase if they are uppercase
2626 """
2727 for i in range (1 , len (word )):
28- if 'A' <= word [i ] <= 'Z' :
29- word = word [:i ] + chr (ord (word [i ]) + 32 ) + word [i + 1 :]
28+ if "A" <= word [i ] <= "Z" :
29+ word = word [:i ] + chr (ord (word [i ]) + 32 ) + word [i + 1 :]
3030
3131 return word
3232
33+
3334def to_title_case (input_str : str ) -> str :
3435 """
3536 Converts a string to title case, preserving the input as is
@@ -50,9 +51,10 @@ def to_title_case(input_str: str) -> str:
5051 words = input_str .split ()
5152 title_case_str = [convert_word (word ) for word in words ]
5253
53- return ' ' .join (title_case_str )
54+ return " " .join (title_case_str )
55+
5456
5557if __name__ == "__main__" :
5658 from doctest import testmod
5759
58- testmod ()
60+ testmod ()
You can’t perform that action at this time.
0 commit comments