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.
Objective
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
else:
print(“The string is not a palindrome”) # if false it is not palindrome
Download source code of this program – click here
Result
Testing
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.
Result
Testing is done and the source code is provided. The result is, that this program is correct. Result is positive.
For more python programs – click here
Input a welcome message and display it in Python
Display the larger / smaller number in Python.
Greatest of Three Numbers in Python using Nested if
Patterns using nested loop in Python
Program to Print Pattern in Python
Program to input the value of x and n and sum of series in Python
Python Program for Armstrong, Prefect Number, Palindrome
Program of Prime number by recursion in python
Prime Number Program in Python
Write a Program to Print Fibonacci Series in Python
Python program to count number of vowels in a string
Whether a String is Palindrome or not in Python
Linear search in python using list
Program to read a text file in python
Python program to read a file line by line
Program to Count Vowels and Consonants in Python
Python Leap Year Program for Beginners
Python Program to Print Series and Addition
Binary Search Program in Python
Program to find sum of digits in python
Sum of numbers divisible by 3 and 5 in python