From 4c032abffa9b71eb483c249dfbdedd2b3c0deee7 Mon Sep 17 00:00:00 2001 From: Saurabh Mahapatra <98408932+its-100rabh@users.noreply.github.com> Date: Sat, 14 Oct 2023 20:58:14 +0530 Subject: [PATCH 1/3] Updated Comments on upper.py --- strings/upper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/strings/upper.py b/strings/upper.py index 5edd40b79808..53886a3adcae 100644 --- a/strings/upper.py +++ b/strings/upper.py @@ -12,9 +12,9 @@ def upper(word: str) -> str: '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 + # Converting to ASCII value, obtaining the integer representation + # and checking to see if the character is a lowercase letter. + # If it is a lowercase letter, it is shifted by 32, making it an uppercase letter. return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word) From cd26f8d6c7394e61442394d542b4cd4701933c39 Mon Sep 17 00:00:00 2001 From: Saurabh Mahapatra <98408932+its-100rabh@users.noreply.github.com> Date: Sat, 14 Oct 2023 22:06:18 +0530 Subject: [PATCH 2/3] Update upper.py --- strings/upper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/upper.py b/strings/upper.py index 53886a3adcae..d134f62930ca 100644 --- a/strings/upper.py +++ b/strings/upper.py @@ -14,7 +14,8 @@ def upper(word: str) -> str: # Converting to ASCII value, obtaining the integer representation # and checking to see if the character is a lowercase letter. - # If it is a lowercase letter, it is shifted by 32, making it an uppercase letter. + # If it is a lowercase letter, + # it is shifted by 32, making it an uppercase letter. return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word) From 02f4de1c05f497c1896f01b8d4f0186c47b5067c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 14 Oct 2023 18:56:38 +0200 Subject: [PATCH 3/3] Update upper.py --- strings/upper.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/strings/upper.py b/strings/upper.py index d134f62930ca..0f68a27b99c6 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,11 +13,6 @@ def upper(word: str) -> str: >>> upper("wh[]32") 'WH[]32' """ - - # Converting to ASCII value, obtaining the integer representation - # and checking to see if the character is a lowercase letter. - # If it is a lowercase letter, - # it is shifted by 32, making it an uppercase letter. return "".join(chr(ord(char) - 32) if "a" <= char <= "z" else char for char in word)