I wrote two simple functions to determine if a string is a palindrome. I thought they were equivalent, but 2 doesn\'t work. Why is this?
1
For strings:
def is_palindrome(s): """Return True if a string is a palindrome.""" return s == s[::-1]
For general iterables (including strings):
def is_palindrome(iterable): """Return True if an iterable is a palindrome.""" if list(iteable) == list(reversed(iterable))