Python Mini Project: Palindrome Checker

Enni Maedani
3 min readNov 29, 2021

--

Photo by Tima Miroshnichenko via Pexels

A palindrome is a word, phrase, or number that reads the same backward as forward, such as “kakak,” “malam,” “isi,” and so on. In this document, I will demonstrate how to create a Mini Project Palindrome Checker using Python.

Import “colored” from “term color” (Optional)

The first step is to import colored from the term color. This changes the text color on the Palindrome Checker to make it more attractive. This step can be skipped if it is deemed unnecessary.

Using the “while” Loop Function

Then, the code is written using the loop function or while loop so that this Palindrome Checker can continue to be used until we break it. Here is the code used:

Note that there is the symbol “\n in the input. This is used to add spacing between the title and input. However, it can be removed if deemed unnecessary.

To ensure that this Palindrome Checker can function properly, it is necessary to standardize the input by doing a lower or upper text conversion to equalize the letters, in order to avoid reading errors. For example, when we input the word “Malam,” where this word is a palindrome. However, because the first “M” letter is capitalized while the others are lowercase, it will be read as not a palindrome word.

After entering all inputs and variables, the if function is used as a condition or criterion for looping.

Then the break command is entered.

Entering the Break Command

As previously explained, the while function requires a break command to stop looping. The method used is as follows:

It is time to run the code. The result will be as follows:

Testing the Palindrome Checker

To check whether the Palindrome Checker works well, try inputting the word “Malam”.

As a result, the Palindrome Checker works well even with different letters. Then try inputting “lanjut” to reuse the Palindrome Checker.

The result also works well, so it can be continued to be used for other words. Now try inputting the word “bintang”.

And it turns out to work well. Next, try inputting the sentence “kasur kakak rusak”.

Then input the numbers “121” and “321”.

As the Palindrome Checker has worked well, it is time to break it by entering the word “keluar”.

Based on the overall results, it can be concluded that this Palindrome Checker works well.

That’s all for this Mini Project. If there are any errors or shortcomings in this note, please feel free to send suggestions or criticisms. Thank you :)

--

--

Enni Maedani

A room of my curiosity, ideas, perspectives, concerns, and a dash of my knowledge.