You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
406 B
Python
17 lines
406 B
Python
5 years ago
|
# Program to check if a string
|
||
|
# is palindrome or not
|
||
|
|
||
|
# change this value for a different output
|
||
|
my_str = 'aIbohPhoBiA'
|
||
|
|
||
|
# make it suitable for caseless comparison
|
||
|
my_str = my_str.casefold()
|
||
|
|
||
|
# reverse the string
|
||
|
rev_str = reversed(my_str)
|
||
|
|
||
|
# check if the string is equal to its reverse
|
||
|
if list(my_str) == list(rev_str):
|
||
|
print("It is palindrome")
|
||
|
else:
|
||
|
print("It is not palindrome")
|