Skip to content

Commit 7139b08

Browse files
Merge pull request #1 from amangoyal0285/amangoyal0285-patch-1
Create Palindrom.py
2 parents 016a11e + f027261 commit 7139b08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Palindrom.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def isPalindrome(n):
2+
reverse = 0
3+
4+
# Copy of the original number so that the original
5+
# number remains unchanged while finding the reverse
6+
temp = abs(n)
7+
while temp != 0:
8+
reverse = (reverse * 10) + (temp % 10)
9+
temp = temp // 10
10+
11+
# If reverse is equal to the original number, the
12+
# number is palindrome
13+
return (reverse == abs(n))
14+
15+
if __name__ == "__main__":
16+
17+
n = 12321
18+
if isPalindrome(n) == True:
19+
print("True")
20+
else:
21+
print("False")

0 commit comments

Comments
 (0)