In this code snippet, we’ll show an example of a Python language function to check if a word is a palindrome (the same backwards).
Python language function to check if a word is a palindrome (the same backwards).
def is_palindrome(word: str) -> bool:
Check if a given word is a palindrome.
word (str): The word to be checked.
bool: True if the word is a palindrome, False otherwise.
return word == word[::-1]
print(is_palindrome("racecar"))
print(is_palindrome("house"))
def is_palindrome(word: str) -> bool:
"""
Check if a given word is a palindrome.
Args:
word (str): The word to be checked.
Returns:
bool: True if the word is a palindrome, False otherwise.
"""
return word == word[::-1]
print(is_palindrome("racecar"))
print(is_palindrome("house"))
def is_palindrome(word: str) -> bool:
"""
Check if a given word is a palindrome.
Args:
word (str): The word to be checked.
Returns:
bool: True if the word is a palindrome, False otherwise.
"""
return word == word[::-1]
print(is_palindrome("racecar"))
print(is_palindrome("house"))
All code from this code snippet package can be downloaded here.
MIT Licensed Code – See License
Tags: python, words, palindrome
RELATED WEBSITES AND SERVICES
These are paid advertisements or products and services ran by ourselves
Privacy preserving, cookieless website visitor tracking for your website completely free. unrive.io
Choose from over 100 quick & easy to use SEO, webmaster and developer tools. seoyex.com
Lorum Ipsum Generator, List Randomiser Tool, List Alphabetizer Tools, Case Converter Tools. seoyex.com
CSS Minifier, JS Minifier, HTML Formatter, CSS Formatter, JS Obfuscator Tools. unrivewebtools.com