1
- def convert_word (word : str ) -> str :
1
+ def to_title_case (word : str ) -> str :
2
2
"""
3
3
Converts a string to capitalized case, preserving the input as is
4
4
5
- >>> convert_word ("Aakash")
5
+ >>> to_title_case ("Aakash")
6
6
'Aakash'
7
7
8
- >>> convert_word ("aakash")
8
+ >>> to_title_case ("aakash")
9
9
'Aakash'
10
10
11
- >>> convert_word ("AAKASH")
11
+ >>> to_title_case ("AAKASH")
12
12
'Aakash'
13
13
14
- >>> convert_word ("aAkAsH")
14
+ >>> to_title_case ("aAkAsH")
15
15
'Aakash'
16
16
"""
17
17
@@ -31,27 +31,24 @@ def convert_word(word: str) -> str:
31
31
return word
32
32
33
33
34
- def to_title_case (input_str : str ) -> str :
34
+ def sentence_to_title_case (input_str : str ) -> str :
35
35
"""
36
36
Converts a string to title case, preserving the input as is
37
37
38
- >>> to_title_case ("Aakash Giri")
38
+ >>> sentence_to_title_case ("Aakash Giri")
39
39
'Aakash Giri'
40
40
41
- >>> to_title_case ("aakash giri")
41
+ >>> sentence_to_title_case ("aakash giri")
42
42
'Aakash Giri'
43
43
44
- >>> to_title_case ("AAKASH GIRI")
44
+ >>> sentence_to_title_case ("AAKASH GIRI")
45
45
'Aakash Giri'
46
46
47
- >>> to_title_case ("aAkAsH gIrI")
47
+ >>> sentence_to_title_case ("aAkAsH gIrI")
48
48
'Aakash Giri'
49
49
"""
50
50
51
- words = input_str .split ()
52
- title_case_str = [convert_word (word ) for word in words ]
53
-
54
- return " " .join (title_case_str )
51
+ return " " .join (to_title_case (word ) for word in input_str .split ())
55
52
56
53
57
54
if __name__ == "__main__" :
0 commit comments