Problem 159538 · easy · Phase 01 Prerequisites & Setup

Is It a Palindrome?

strings · slicing · string methods

A palindrome reads the same forwards and backwards, like racecar or level.

Write a function is_palindrome(s) that returns True if the string s is a palindrome and False otherwise. Ignore the difference between upper- and lower-case letters, so Level counts as a palindrome. Do not worry about spaces or punctuation; the inputs only contain letters.

Examples

Input:  s = "racecar"
Output: True
Input:  s = "Level"
Output: True
Explanation: After lower-casing, "level" reversed is still "level".
Input:  s = "hello"
Output: False

Constraints

  • 0 <= len(s) <= 100
  • s contains only letters. The empty string counts as a palindrome.

Goals

  • Reverse a string with slicing
  • Make a comparison case-insensitive with .lower()
  • Compare two strings with ==
Starting Python…