Created
September 11, 2022 12:02
-
-
Save Robotboy93/a894a860ec5a46077c88b05f343fd118 to your computer and use it in GitHub Desktop.
Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def isPalindrome(self, x: int) -> bool: | |
c = 0 | |
z = [y for y in str(x)] | |
for i in range(len(z)//2): | |
if z[i] != z[len(z)-1-i]: | |
c = c+1 | |
break | |
return(1-c) | |
pass | |
ret = Solution().isPalindrome(12321) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment