Palindrome Detective ๐ต๏ธ
A palindrome is a word that reads the same forwards and backwards: racecar, kayak, level, wow. ๐
Your job: build a function that can spot one.
def shout(word):
return word.upper() + "!"
print(shout("hello")) # โ HELLO!
return hands the answer back to whoever called the function.
That's different from print(), which just splats it on the screen โ
a returned value can be used in an if, stored in a variable, or
tested by me. ๐งช
A comparison like word == word[::-1] is already True or False,
so you can hand that straight back:
def is_long(word):
return len(word) > 5
Your mission
Write a function called is_palindrome that takes a word and
returns True if it reads the same backwards, False if it
doesn't.
I'll test it with racecar, kayak, banana and more. return โ don't
print! ๐ฏ
Your code
Press โถ Run to see what your code does!