Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions strings/word_phrase_int_palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def is_palindrome(input_value):
# Convert the input to a string and remove spaces and special characters (for phrases)

Check failure on line 2 in strings/word_phrase_int_palindrome.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

strings/word_phrase_int_palindrome.py:2:89: E501 Line too long (90 > 88)
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