F3. Palindrome

Problem: Palindrome
Given: A sequence S
Question: A function that returns True if and only if S is a palindrome: i.e., is the same sequence when reversed.

For example:

  • [1,2,3,3,2,1] is a palindrome.
  • ['a','b','b','b'] is not a palindrome.
  • [1,'2',2,'1'] is not a palindrome.

Hint: This is trickier than it looks if you try to do it the obvious way. You'll need to study the Python built-in function reversed() carefully and do some experimentation.

Last modified: Thursday, 10 July 2014, 5:36 PM