Skip to content

Commit 5c360b0

Browse files
Update 9. Palindrome Number.py
1 parent 0c46245 commit 5c360b0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

python/easy/9. Palindrome Number.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
class Solution:
22
def isPalindrome(self, x: int) -> bool:
3-
str_forward = str(x)
4-
str_backward = str_forward[::-1]
5-
return str_forward == str_backward
3+
"""
4+
isPalindrome returns true or false depending on if x int input is a palindrome number
5+
palindrome numbers are the same forward as they are backwards
6+
x: int (-231 <= x <= 231 - 1)
7+
"""
8+
str_forward = str(x) #convert x int to str
9+
str_backward = str_forward[::-1] #reverse str
10+
return str_forward == str_backward #return comparison of forward and backwards str

0 commit comments

Comments
 (0)