Skip to content

Instantly share code, notes, and snippets.

@Robotboy93
Created September 11, 2022 12:02
Show Gist options
  • Save Robotboy93/a894a860ec5a46077c88b05f343fd118 to your computer and use it in GitHub Desktop.
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.
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