From c7b54a07a666c2d47395fac93e921b4de0447c52 Mon Sep 17 00:00:00 2001 From: SaicoBys Date: Fri, 4 Apr 2025 15:43:01 -0500 Subject: [PATCH 1/2] Add is_palindrome algorithm under strings category --- strings/is_palindrome.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 strings/is_palindrome.py diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py new file mode 100644 index 000000000000..a235ce1d4177 --- /dev/null +++ b/strings/is_palindrome.py @@ -0,0 +1,15 @@ +def is_palindrome(txt): + """ + Checks if a given text is a palindrome. + + A palindrome is a word or phrase that reads the same forwards and backwards. + + Parameters: + txt (str): The text to check. + + Returns: + bool: True if the text is a palindrome, False otherwise. + """ + return txt == txt[::-1] + +print(is_palindrome("radar")) From 1e9fcd7ba2f9e37b58ee5109ab3b339cc6766d49 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 20:44:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/is_palindrome.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/strings/is_palindrome.py b/strings/is_palindrome.py index a235ce1d4177..edf35264e494 100644 --- a/strings/is_palindrome.py +++ b/strings/is_palindrome.py @@ -11,5 +11,6 @@ def is_palindrome(txt): bool: True if the text is a palindrome, False otherwise. """ return txt == txt[::-1] - + + print(is_palindrome("radar"))