From 23b19f8a5de8463c2b8c3e765827ff1e1e04817d Mon Sep 17 00:00:00 2001 From: Saurabh Mahapatra <98408932+its-100rabh@users.noreply.github.com> Date: Mon, 16 Oct 2023 10:38:15 +0530 Subject: [PATCH 1/2] Update capitalize.py --- strings/capitalize.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/strings/capitalize.py b/strings/capitalize.py index e7e97c2beb53..3446143c2aaf 100644 --- a/strings/capitalize.py +++ b/strings/capitalize.py @@ -3,7 +3,13 @@ def capitalize(sentence: str) -> str: """ - This function will capitalize the first letter of a sentence or a word + Capitalizes the first letter of a sentence or word. + + :param sentence: The input sentence or word to be capitalized. + :return: The sentence with the first letter capitalized. + + Examples: + >>> capitalize("hello world") 'Hello world' >>> capitalize("123 hello world") @@ -17,6 +23,10 @@ def capitalize(sentence: str) -> str: """ if not sentence: return "" + + # Create a dictionary that maps lowercase letters to uppercase letters + # Capitalize the first character if it's a lowercase letter + # Concatenate the capitalized character with the rest of the string lower_to_upper = dict(zip(ascii_lowercase, ascii_uppercase)) return lower_to_upper.get(sentence[0], sentence[0]) + sentence[1:] From 742bc0393fb74864839d53b0787efb3da92ca8eb Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Thu, 26 Oct 2023 04:19:36 -0400 Subject: [PATCH 2/2] Update strings/capitalize.py --- strings/capitalize.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/strings/capitalize.py b/strings/capitalize.py index 3446143c2aaf..c0b45e0d9614 100644 --- a/strings/capitalize.py +++ b/strings/capitalize.py @@ -5,11 +5,6 @@ def capitalize(sentence: str) -> str: """ Capitalizes the first letter of a sentence or word. - :param sentence: The input sentence or word to be capitalized. - :return: The sentence with the first letter capitalized. - - Examples: - >>> capitalize("hello world") 'Hello world' >>> capitalize("123 hello world")