LeetCode/NeetCodeRoadmap/Arrays_and_Hashing/125_Valid_Palindrome.py
2023-08-28 23:45:49 -07:00

22 lines
603 B
Python

import string
def isPalindrome(s):
"""
:type s: str
:rtype: bool
"""
# Create a translation table to remove uppercase letters and special characters
translation_table = str.maketrans("", "", string.ascii_uppercase + string.punctuation + string.whitespace)
# Use the translation table to remove uppercase letters and special characters
cleaned_string = s.translate(translation_table)
half = len(cleaned_string)/2
first = []
second = []
for i in range(len(half)):
return cleaned_string
print(isPalindrome("A man, a plan, a canal: Panama"))