Input a string and determine whether it is a palindrome or not in Python. This python project is useful for beginners and CBSE KV School Class 11 and Class 12 students computer science practical file and NIELIT O Level module. This also come as basic question for private organization interview. So, it is better to remember and learn.
Write a program to input a string and determine whether it is a palindrome or not in Python
Screenshot of Whether a String is Palindrome or not in Python
Explanation of Source code
string = input(“Enter the string:”) # the string to checked if palindrome
if(string == string[::-1]): #if string is equal to reverse
print(“The string is a palindrome”) # if true it is palindrome
print(“The string is not a palindrome”) # if false it is not palindrome
Download source code of this program – click here
first arcra is input and reverse of it is arcra which is same as input so it is a palindrome.
second archit is input and reverse of it is tihcra which is not same so it is not palindrome.
Testing is done and the source code is provided. The result is, that this program is correct. Result is positive.