Write A Python Program To Test A String Is A Palindrome Or Not

Hi Programmers, welcome to my blog, lets try to get python solution for write a python program to test a string is a palindrome or not.







Title :

Python Problem : Write A Python Program To Test A String Is A Palindrome Or Not


Description :

Ask user to enter a string, once user enters compare it with its reverse using string slicing technique ::-1 if result is true print palindrome. Else print not a palindrome, nan


Code :

my_string = input("Enter a string :")
if my_string == my_string[::-1]:
    print("String is palindrome")
else:
    print("String is not palindrome")


Conclusion :

Once you are done with reading the above code, open your python editor, try to write the program by yourself. This will improve your coding skills, try changing variable names, change operators and execute it.

Thank you for reading my article about write a python program to test a string is a palindrome or not if you have any queries about above solution, please comment down below, if you like this article share it with your friends.