Categories
General Programming

Palindrome Day – with Python

Although today feels like any other day, it isn’t (if you actually find fascination in numbers). Today is a palindrome day! No, it’s not a holiday nor is it any sort of celebration or festive.

A palindrome, according to Oxford dictionary, is “a word, phrase, or sequence that reads the same backwards as forwards”. Today’s date, 02-02-2020, is a palindrome. It has the same sequence when it is read forward or backwards, 0202 2020.

Dates are written in different formats, depending on one’s preference. Although you’d be able to spot palindromic dates on other years depending on the date format, today is palindrome no matter which format you write today’s date in, DDMMYYYY, MMDDYYYY, YYYYMMDD or YYYYDDMM. The last palindromic date that satisfies all the formats was 909 years ago, 11/11/1111. The next such palindromic date would come in 101 years on 12/12/2121. I doubt many of us reading this would live to see the next palindrome day.

Out of curiosity, I’ve written a script in Python to check for palindrome. You can find my code below, on GitHub or run it here.

def palindrome(word): 
    revword = word[::-1]
    if (word.lower() == revword.lower()): 
        return True
    return False

word = input('Enter word/number: ')
check = palindrome(word) 

if (check): 
    print(word+" is a palindrome") 
else: 
    print(word+" is a not palindrome")