Palindrome Check Practice Problem
This data science coding problem helps you practice String Manipulation, palindrome check, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of String Manipulation.
- Problem ID: 98
- Problem key: 98-palindrome-check
- URL: https://datacrack.app/solve/98-palindrome-check
- Difficulty: easy
- Topic: String Manipulation
- Module: Python Fundamentals
Problem Statement
# 🧩 Palindrome Check
---
### 🎯 Goal
A palindrome reads the same forwards and backwards. This problem teaches **string reversal and comparison** — and introduces the **two-pointer technique**, one of the most important algorithmic patterns for sequence problems.
---
### 🔍 What Is a Palindrome?
```
"racecar" → True (r-a-c-e-c-a-r reversed = r-a-c-e-c-a-r)
"hello" → False (hello reversed = olleh)
"madam" → True
```
---
### 💻 Task
Implement `is_palindrome(s)`. Use **string slicing** for a one-line solution.
---
### 📥 Input
- `s`: a lowercase string (no spaces or punctuation)
### 📤 Output
- `bool` — `True` if the string is a palindrome, `False` otherwise
---
### 🧩 Starter Code
```python
def is_palindrome(s):
"""
Check if a string reads the same forwards and backwards.
Args:
s (str): Lowercase string
Returns:
bool: True if palindrome, False otherwise
"""
# 🧠 TODO: Compare the string to its reverse
# Hint: s[::-1] reverses a string
pass
```
---
### 💡 Example
```python
is_palindrome("racecar") # Expected: True
is_palindrome("hello") # Expected: False
is_palindrome("a") # Expected: True (single character)
```
---
### 🔑 Key Concepts
- `s[::-1]` reverses a string
- Comparing `s == s[::-1]` is the cleanest solution
- A single character is always a palindromeStarter Code
def is_palindrome(s):
"""
Check if a string reads the same forwards and backwards.
Args:
s (str): Lowercase string
Returns:
bool: True if palindrome, False otherwise
"""
# 🧠 TODO: Compare the string to its reverse
# Hint: s[::-1] reverses a string
pass