From 5600c8ceb55fdd41389576cae6d217b407796b9e Mon Sep 17 00:00:00 2001 From: Yashi Gupta <98335217+yashigupta4623@users.noreply.github.com> Date: Sun, 25 Jun 2023 13:34:12 +0530 Subject: [PATCH] update palindrome_number.py with string approach In this commit, I tried to approach the check for Palindrome number using String approach. --- Code/Python/palindrome_number.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Code/Python/palindrome_number.py b/Code/Python/palindrome_number.py index 68bfb96a9..86445f9ae 100644 --- a/Code/Python/palindrome_number.py +++ b/Code/Python/palindrome_number.py @@ -39,3 +39,25 @@ # OUTPUT: # The given number is a palindrome. + + +'''Solution No. 2 Using String ''' +n = int(input()) +n_str = str(n) #convert it into string in order to do slicing +n_str = int(n_str[::-1]) #reversed the order by slicing + +if n_str == n: + print("The given number is a Palindrome number.") +else: + print("The given number is not a Palindrome number.") + + +#TEST CASES : + +'''1. Enter the number : 1252153374328989 +The given number is not a Palindrome number.''' + +'''2.Enter the number : 23455432 +The given number is a Palindrome number.''' + +