0PricingLogin
Competitive Programming Academy · Lesson

Palindrome Checks Done Right

Compare from both ends efficiently.

What Is a Palindrome

A palindrome reads the same forward and backward, like racecar or level. Checking for one is a classic warm-up problem. 🔁

The Slice Trick

Python can reverse a string with the slice s[::-1]. Compare it to the original and you have a one-line check.

s = 'level'
print(s == s[::-1])  # True

All lessons in this course

  1. Characters, ord & chr Tricks
  2. Count Letters with a Frequency Table
  3. Palindrome Checks Done Right
  4. Split, Strip & Rejoin Words
← Back to Competitive Programming Academy