From 78808e7aa33aa92ef77e97f3df699e906cccc718 Mon Sep 17 00:00:00 2001 From: sarveshsrinath Date: Sat, 19 Oct 2024 13:23:32 +0530 Subject: [PATCH 1/3] Added a palindrome checker for phrases/words/integers. Added one file named is_string_palindrome.py Which checks if a given phrase/word or integer is in palindrome. --- maths/is_string_palindrome.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 maths/is_string_palindrome.py diff --git a/maths/is_string_palindrome.py b/maths/is_string_palindrome.py new file mode 100644 index 000000000000..9e3382926060 --- /dev/null +++ b/maths/is_string_palindrome.py @@ -0,0 +1,7 @@ +def is_string_palindrome(words: str) -> bool: + cleaned_phrase = ''.join(words.split()).lower() + return cleaned_phrase == cleaned_phrase[::-1] + +if __name__ == "__main__": + n=input("Enter a word:-") + print(is_string_palindrome(n)) \ No newline at end of file From a2bee237ea05fc4a18edaa542867323700b28f75 Mon Sep 17 00:00:00 2001 From: sarveshsrinath Date: Sat, 19 Oct 2024 13:34:20 +0530 Subject: [PATCH 2/3] Formatted the code to follow rules. Adding adequate spacing to the code. --- maths/is_string_palindrome.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/maths/is_string_palindrome.py b/maths/is_string_palindrome.py index 9e3382926060..1cc5dfe1006b 100644 --- a/maths/is_string_palindrome.py +++ b/maths/is_string_palindrome.py @@ -2,6 +2,7 @@ def is_string_palindrome(words: str) -> bool: cleaned_phrase = ''.join(words.split()).lower() return cleaned_phrase == cleaned_phrase[::-1] + if __name__ == "__main__": - n=input("Enter a word:-") - print(is_string_palindrome(n)) \ No newline at end of file + word = input("Enter a word:-") + print(is_string_palindrome(word)) \ No newline at end of file From 9a0f701ca639de76c684545640067ca09ce2e39f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 08:08:09 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/is_string_palindrome.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maths/is_string_palindrome.py b/maths/is_string_palindrome.py index 1cc5dfe1006b..5add3bcd249e 100644 --- a/maths/is_string_palindrome.py +++ b/maths/is_string_palindrome.py @@ -1,8 +1,8 @@ def is_string_palindrome(words: str) -> bool: - cleaned_phrase = ''.join(words.split()).lower() + cleaned_phrase = "".join(words.split()).lower() return cleaned_phrase == cleaned_phrase[::-1] if __name__ == "__main__": word = input("Enter a word:-") - print(is_string_palindrome(word)) \ No newline at end of file + print(is_string_palindrome(word))