File tree 1 file changed +7
-5
lines changed
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:
18
18
"""
19
19
Convert the first character to uppercase if it's lowercase
20
20
"""
21
- if 'a' <= word [0 ] <= 'z' :
21
+ if "a" <= word [0 ] <= "z" :
22
22
word = chr (ord (word [0 ]) - 32 ) + word [1 :]
23
23
24
24
"""
25
25
Convert the remaining characters to lowercase if they are uppercase
26
26
"""
27
27
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 :]
30
30
31
31
return word
32
32
33
+
33
34
def to_title_case (input_str : str ) -> str :
34
35
"""
35
36
Converts a string to title case, preserving the input as is
@@ -50,9 +51,10 @@ def to_title_case(input_str: str) -> str:
50
51
words = input_str .split ()
51
52
title_case_str = [convert_word (word ) for word in words ]
52
53
53
- return ' ' .join (title_case_str )
54
+ return " " .join (title_case_str )
55
+
54
56
55
57
if __name__ == "__main__" :
56
58
from doctest import testmod
57
59
58
- testmod ()
60
+ testmod ()
You can’t perform that action at this time.
0 commit comments