Skip to content

Commit 185ef19

Browse files
Simplify implementation (#14654)
Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 4 to 5. - [Release notes](https://github.com/actions/upload-pages-artifact/releases) - [Commits](actions/upload-pages-artifact@v4...v5) --- updated-dependencies: - dependency-name: actions/upload-pages-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent b995597 commit 185ef19

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎strings/capitalize.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ def capitalize(sentence: str) -> str:
1313
>>> capitalize("")
1414
''
1515
"""
16-
if not sentence:
17-
return ""
1816

1917
# Capitalize the first character if it's a lowercase letter
2018
# Concatenate the capitalized character with the rest of the string
21-
return sentence[0].upper() + sentence[1:]
19+
# Slicing keeps this safe for empty strings.
20+
return sentence[:1].upper() + sentence[1:]
2221

2322

2423
if __name__ == "__main__":

0 commit comments

Comments
 (0)