Lesson 6
Dealing with Sequences of Objects
Chapter 8: Strings as a sequence
Palindromes
What better way to practise using strings as sequence of characters by applying them to a practical task?
Your first task is to write a function is_palindrome() to check whether a given string is a palindrome.
A palindrome is a word that reads the same forwards and backwards. Example: madam, level, rotator, noon, kayak, civic, malayalam.
For this challenge, you can assume that the input string will be a single word made up of lowercase letters only. I will ask you to implement a version that handles more complex cases in a future lesson! 😈
Your function should return True if the input string is a palindrome. It should return False if the string is not a palindrome.
This should be a very quick exercise! My own solution only required a single line in the function body!
Sample inputs and outputs
>>> is_palindrome("kayak")
True
>>> is_palindrome("malayalam")
True
>>> is_palindrome("python")
False
>>> is_palindrome("hello")
False