beginner
Check Palindrome
Check if a string is a palindrome.
A palindrome reads the same forwards and backwards.
📚 Concepts & Theory
Palindromes
is_palindrome = text == text[::-1] 🎯 Your Challenge
Write is_palindrome that returns True/False.
📝 Starter Code
Python
def is_palindrome(text):
pass
print(is_palindrome('radar'))
Solution
Python
def is_palindrome(text):
text = text.lower().replace(' ', '')
return text == text[::-1]
print(is_palindrome('radar'))
Explanation
Compare string with its reverse.
❓ Frequently Asked Questions
Reads same both ways