Created
February 22, 2020 22:08
-
-
Save BharathKumarS/ccc3c99a9e8ff5d642ff2df55b6d6df6 to your computer and use it in GitHub Desktop.
LeetCode - Check for Palindrome - Check for 3 line code solution on my git repo
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
#Can you believe I wrote another solution with just 3 lines of code? Check my Git repo for the actual code! | |
class Palindrome: | |
def text(self, set_of_chars): | |
rev = clean = '' | |
for char in set_of_chars[::-1]: | |
if char.isalnum(): | |
rev = rev + char.lower() | |
for ele in set_of_chars[::1]: | |
if ele.isalnum(): | |
clean = clean + ele.lower() | |
print(clean == rev) | |
if __name__ == '__main__': | |
cObj = Palindrome() | |
cObj.text(str(input())) |
Author
BharathKumarS
commented
Feb 22, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment