Computer Science, asked by bachipodila, 3 months ago

write aprogram to check whether the given string is a palindrone Or not in python string program​

Answers

Answered by anindyaadhikari13
1

Required Answer:-

Question:

  • Write a python program to check whether a given string is palindrome or not.

Solution:

1. Using loops.

s=input("Enter a string: ")

m=""

for i in range(len(s)-1,-1,-1):

m+=s[i]

if s==m:

print("Palindrome.")

else:

print("Not Palindrome.")

2. Using string slicing.

s=input("Enter a String: ")

if s==s[::-1]:

print("Palindrome.")

else:

print("Not Palindrome.")

Algorithm:

  1. START
  2. Ask the user to enter a string.
  3. Find the reverse of the string.
  4. Check if the reversed string and the original string are same or not. If true, then the string is palindrome else not.
  5. Display the result.
  6. STOP.

Check out the attachment for output ☑.

Attachments:
Similar questions