Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

is plaindrome python

def is_palindrome(s):
      	#check if it's a string
    if type(s) != str:
        raise ValueError("This is not a string")
    #return list of capital letters ignore other characters such as (, ! ? ...)
    l1 = list(map(lambda x : x.isalpha and x.upper(), s))
    #remove False from list 
    l1 = [x for x in l1 if x != False]
    #reverse the previous list 
    l2 = list(reversed(l1))
    # check is l1 equal to l2 ?
    return l1 == l2


print(is_palindrome(input("Enter a string ")))
Comment

PREVIOUS NEXT
Code Example
Python :: python get time executed by function 
Python :: beautiful soup find 
Python :: upload file django 
Python :: python - How to subtract values from dictionaries 
Python :: try except to specific line 
Python :: treesitter python 
Python :: 4D Array To DF 
Python :: write a python program to find the second largest number in a list 
Python :: python print 2d array as table 
Python :: tkinter label border color 
Python :: search for list of strings in pandas column 
Python :: generate a list with random length and with random numbers python 
Python :: pandas transform count where condition 
Python :: pandas show all dataframe method 
Python :: split list python percent 
Python :: join list of string into a single string with comma 
Python :: django 3 create async rest api 
Python :: id3 algorithm code in python 
Python :: clipboard python 
Python :: eval in python 
Python :: django permissions 
Python :: django set default value for model not form 
Python :: null in python 
Python :: python dataframe sort by column name 
Python :: python increase one item in list 
Python :: wkhtmltopdf pdfkit blocked access to file 
Python :: Pass arguments in button tkinter 
Python :: pandas is nattype 
Python :: python set split limit 
Python :: python class example 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =