mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Merge 6145f97757
into f3f32ae3ca
This commit is contained in:
commit
6ae4b0e44f
13
strings/word_phrase_int_palindrome.py
Normal file
13
strings/word_phrase_int_palindrome.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
def is_palindrome(input_value):
|
||||
# Convert the input to a string and remove spaces and special characters (for phrases)
|
||||
sanitized_value = "".join(filter(str.isalnum, str(input_value))).lower()
|
||||
|
||||
# Check if the sanitized string is equal to its reverse
|
||||
return sanitized_value == sanitized_value[::-1]
|
||||
|
||||
|
||||
input_value = input("Enter a phrase, word, or number to check if it's a palindrome: ")
|
||||
if is_palindrome(input_value):
|
||||
print("The input is a palindrome.")
|
||||
else:
|
||||
print("The input is not a palindrome.")
|
Loading…
Reference in New Issue
Block a user