converts a string to capitalized case preserving the input as is totitlecaseaakash aakash totitlecaseaakash aakash totitlecaseaakash aakash totitlecaseaakash aakash convert the first character to uppercase if it s lowercase convert the remaining characters to lowercase if they are uppercase converts a string to title case preserving the input as is sentencetotitlecaseaakash giri aakash giri sentencetotitlecaseaakash giri aakash giri sentencetotitlecaseaakash giri aakash giri sentencetotitlecaseaakash giri aakash giri converts a string to capitalized case preserving the input as is to_title_case aakash aakash to_title_case aakash aakash to_title_case aakash aakash to_title_case aakash aakash convert the first character to uppercase if it s lowercase convert the remaining characters to lowercase if they are uppercase 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_case aakash giri aakash giri
def to_title_case(word: str) -> str:
    

    
    if "a" <= word[0] <= "z":
        word = chr(ord(word[0]) - 32) + word[1:]

    
    for i in range(1, len(word)):
        if "A" <= word[i] <= "Z":
            word = word[:i] + chr(ord(word[i]) + 32) + word[i + 1 :]

    return word


def sentence_to_title_case(input_str: str) -> str:
    

    return " ".join(to_title_case(word) for word in input_str.split())


if __name__ == "__main__":
    from doctest import testmod

    testmod()