Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update palindrome_number.py with string approach #2107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Code/Python/palindrome_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'''