We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d219a3c commit c22d862Copy full SHA for c22d862
strings/capitalize.py
@@ -16,14 +16,9 @@ def capitalize(sentence: str) -> str:
16
if not sentence:
17
return ""
18
19
- # Get the first character of the sentence
20
- first_char = sentence[0]
21
- # Check if the first character is a lowercase letter
22
- if "a" <= first_char <= "z":
23
- # Convert the lowercase letter to uppercase using ASCII value
24
- first_char = chr(ord(first_char) - 32)
25
- # Return the capitalized first character concatenated with the rest of the sentence
26
- return first_char + sentence[1:]
+ # Capitalize the first character if it's a lowercase letter
+ # Concatenate the capitalized character with the rest of the string
+ return sentence[0].upper() + sentence[1:]
27
28
29
if __name__ == "__main__":
0 commit comments