Skip to content

Commit

Permalink
palindrome number check
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdhebarin committed Aug 26, 2018
1 parent 764c53f commit b9e14f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Practice/leetcode3_palindrome_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def palindromenumber(num):

i = 0
temp = 0
s = str(num)

if len(s) == 1:
return int(s)

else:

while i <= len(s)-1:
rem = num % 10
temp = temp * 10 + rem
num = num // 10
i += 1

if temp == int(s):
return True

else:
return False

print(palindromenumber(121))

0 comments on commit b9e14f1

Please sign in to comment.