strings.palindrome

Attributes

test_data

test_data_ignore_case_and_spaces

Functions

benchmark_function(→ None)

is_palindrome(→ bool)

Return True if s is a palindrome otherwise return False.

is_palindrome_ignore_case_and_spaces(→ bool)

Return True if s is a palindrome, ignoring case, spaces, and punctuation.

is_palindrome_recursive(→ bool)

Return True if s is a palindrome otherwise return False.

is_palindrome_slice(→ bool)

Return True if s is a palindrome otherwise return False.

is_palindrome_traversal(→ bool)

Return True if s is a palindrome otherwise return False.

Module Contents

strings.palindrome.benchmark_function(name: str) None
strings.palindrome.is_palindrome(s: str) bool

Return True if s is a palindrome otherwise return False.

>>> all(is_palindrome(key) == value for key, value in test_data.items())
True
strings.palindrome.is_palindrome_ignore_case_and_spaces(s: str) bool

Return True if s is a palindrome, ignoring case, spaces, and punctuation. Otherwise return False.

>>> is_palindrome_ignore_case_and_spaces("A man a plan a canal Panama")
True
>>> is_palindrome_ignore_case_and_spaces("Was it a car or a cat I saw?")
True
>>> is_palindrome_ignore_case_and_spaces("Hello World")
False
>>> is_palindrome_ignore_case_and_spaces("Never Odd or Even")
True
>>> is_palindrome_ignore_case_and_spaces("")
True
strings.palindrome.is_palindrome_recursive(s: str) bool

Return True if s is a palindrome otherwise return False.

>>> all(is_palindrome_recursive(key) == value for key, value in test_data.items())
True
strings.palindrome.is_palindrome_slice(s: str) bool

Return True if s is a palindrome otherwise return False.

>>> all(is_palindrome_slice(key) == value for key, value in test_data.items())
True
strings.palindrome.is_palindrome_traversal(s: str) bool

Return True if s is a palindrome otherwise return False.

>>> all(is_palindrome_traversal(key) == value for key, value in test_data.items())
True
strings.palindrome.test_data
strings.palindrome.test_data_ignore_case_and_spaces