diff --git a/strings/capitalize.py b/strings/capitalize.py index 63603aa07e2d..e7f4900f1ada 100644 --- a/strings/capitalize.py +++ b/strings/capitalize.py @@ -1,6 +1,3 @@ -from string import ascii_lowercase, ascii_uppercase - - def capitalize(sentence: str) -> str: """ This function will capitalize the first letter of a sentence or a word @@ -14,11 +11,12 @@ def capitalize(sentence: str) -> str: 'A' >>> capitalize("") '' + >>> capitalize("ö") + 'Ö' """ if not sentence: return "" - lower_to_upper = {lc: uc for lc, uc in zip(ascii_lowercase, ascii_uppercase)} - return lower_to_upper.get(sentence[0], sentence[0]) + sentence[1:] + return sentence[0].upper() + sentence[1:] if __name__ == "__main__":