From f968dda5e9b81bd7dd3c5e9b7a69a9a08ed3ead7 Mon Sep 17 00:00:00 2001 From: Saurabh Mahapatra <98408932+its-100rabh@users.noreply.github.com> Date: Sun, 15 Oct 2023 00:32:37 +0530 Subject: [PATCH] Updated Comments on upper.py (#10442) * Updated Comments on upper.py * Update upper.py * Update upper.py --------- Co-authored-by: Christian Clauss --- strings/upper.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/strings/upper.py b/strings/upper.py index 5edd40b79..0f68a27b9 100644 --- a/strings/upper.py +++ b/strings/upper.py @@ -1,6 +1,8 @@ def upper(word: str) -> str: """ - Will convert the entire string to uppercase letters + Convert an entire string to ASCII uppercase letters by looking for lowercase ASCII + letters and subtracting 32 from their integer representation to get the uppercase + letter. >>> upper("wow") 'WOW' @@ -11,10 +13,6 @@ def upper(word: str) -> str: >>> upper("wh[]32") 'WH[]32' """ - - # Converting to ascii value int value and checking to see if char is a lower letter - # if it is a lowercase letter it is getting shift by 32 which makes it an uppercase - # case letter return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word)