๐งช Programming
โฑ๏ธ 85s
๐ 959 chars
๐ฆ 8.0B
๐ง Q4_K_M
Prompt: Write a Python function is_palindrome(s) that returns True if s is a palindrome. One test case.
Response
**Palindrome Function**
=======================
The following Python function checks whether a given string `s` is a
palindrome.
```python
def is_palindrome(s):
"""
Returns True if the input string is a palindrome, False otherwise.
:param s: Input string to check for palindrome
:return: Boolean indicating whether the input string is a palindrome
"""
return s == s[::-1]
```
**Explanation**
---------------
This function uses Python's slice notation `s[::-1]` to reverse the input s
string. It then compares the reversed string with the original string using
using equality operator `==`. If they are equal, the function returns
`True`, indicating that the string is a palindrome.
**Example Use Case**
---------------------
```python
print(is_palindrome("madam")) # Output: True
```
This test case demonstrates that the function correctly identifies "madam"
as a palindrome.