Palindrome !?
Rotavator #
Palindrome? What is it !? #
- Its just a fancy term for saying something like this:
- string/integer matches to their reverse.
- Example: POP equals to POP(reverse of pop)
- Another example: madam equals to madam(reverse of madam)
Yet another example: Rotavator equals to rotvatoR(reverse of rotavator)
- non-examples aka false statements:
- “Hello world” equals to “dlrow olleH”
“definetly not” equals to “ton yltenifed”
- Python code for this type of program
data = input("Enter something: ")
def is_palindrome(data):
reverse = data[::-1]
if data == reverse:
print("Yes")
return True
print("Nope")
return False
is_palindrome(data)
- suggested improvements:
- we can use manual function for string reversal
- instead of using python slicling magic.