reversed does not create a string, but a reverse object:
>>> reversed('radar') <reversed object at 0x1102f99d0>
Thus, the string 'radar' does not compare with the reversed('radar') object. For it to work, you must ensure that the reversed object is actually evaluated:
def is_palindrome(string): if string == u''.join(reversed(string)): return True else: return False
u''.join(reversed(string)) inserts u'' between each of the characters in the string, and this causes the return string to turn into a string object.
source share