Friday, December 27, 2019

Python program to check if a string is palindrome or not

Python program to check if a string is palindrome or not

Answer:

my_str = 'Madam'
my_str = my_str.casefold()

rev_str = reversed(my_str)

if list(my_str) == list(rev_str):
   print("The string is a palindrome.")
else:
   print("The string is not a palindrome.")


Output:

The string is a palindrome.

No comments:

Post a Comment

Featured posts

स्मार्ट इन्वेस्टिंग फॉर बिगिनर्स:

 स्मार्ट इन्वेस्टिंग फॉर बिगिनर्स:  पैसिव इनकम कमाने का आसान रास्ता"।  इसमें मैंने बताया है कि कैसे छोटी रकम से शुरुआत करके, म्यूचुअल फ...

Popular posts