MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / sentence_to_title_case

Function sentence_to_title_case

strings/title.py:34–51  ·  view source on GitHub ↗

Converts a string to title case, preserving the input as is >>> sentence_to_title_case("Aakash Giri") 'Aakash Giri' >>> sentence_to_title_case("aakash giri") 'Aakash Giri' >>> sentence_to_title_case("AAKASH GIRI") 'Aakash Giri' >>> sentence_to_title_c

(input_str: str)

Source from the content-addressed store, hash-verified

32
33
34def sentence_to_title_case(input_str: str) -> str:
35 """
36 Converts a string to title case, preserving the input as is
37
38 >>> sentence_to_title_case("Aakash Giri")
39 'Aakash Giri'
40
41 >>> sentence_to_title_case("aakash giri")
42 'Aakash Giri'
43
44 >>> sentence_to_title_case("AAKASH GIRI")
45 'Aakash Giri'
46
47 >>> sentence_to_title_case("aAkAsH gIrI")
48 'Aakash Giri'
49 """
50
51 return " ".join(to_title_case(word) for word in input_str.split())
52
53
54if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

to_title_caseFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected