You may have probably seen many solutions for checking whether a string is palindrome or not. But we are not going to see that again in here.
In this article, we will see how to make a palindrome from a string in Python.
def pal(s): l = len(s) p = s + s[-1-l%2 :: -1] return p print("A palindrome from 'malay' is ", pal('malay')) print("A palindrome from 'abc' is ", pal('abc'))
A palindrome from 'malay' is malayalam A palindrome from 'abc' is abcba