Skip to content

Commit 2da0067

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a33e4f8 commit 2da0067

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: strings/title.py

+7-5
Original file line numberDiff line numberDiff 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+
3334
def 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

5557
if __name__ == "__main__":
5658
from doctest import testmod
5759

58-
testmod()
60+
testmod()

0 commit comments

Comments
 (0)