🏠 Home 📚 Chapters 💻 Projects ℹ️ About
HomeProjects › Day 10
DAY 10 — 60 DAY PYTHON CHALLENGE

💻 Palindrome Checker

Python में Palindrome Checker — पैलिंड्रोम क्या होता है?

Advertisement

Complete Code

python — day10.py
def is_palindrome(text):
    clean = text.lower().replace(" ", "")
    return clean == clean[::-1]

def palindrome_checker():
    print("🔄 Palindrome Checker")
    print("Palindrome = आगे-पीछे same")
    print("-" * 30)

    examples = ["madam", "racecar", "level",
                "python", "hello", "civic"]

    print("\n📋 Examples:")
    for word in examples:
        icon = "✅" if is_palindrome(word) else "❌"
        print(f"  {icon} '{word}'")

    print("\n🔍 अपना word check करें:")
    while True:
        word = input("Word (q=quit): ")
        if word.lower() == "q":
            break
        if is_palindrome(word):
            print(f"  ✅ '{word}' Palindrome है!")
        else:
            rev = word[::-1]
            print(f"  ❌ Palindrome नहीं | Reverse: '{rev}'")

palindrome_checker()
OUTPUT
📋 Examples: ✅ 'madam' ✅ 'racecar' ✅ 'level' ❌ 'python' ❌ 'hello' ✅ 'civic'

यह Code कैसे काम करता है?

[::-1] Python का सबसे आसान string reverse method है। lower() और replace() से case और spaces ignore होते हैं। 'A man a plan a canal Panama' भी palindrome है!
Advertisement