sec_7.py
Problem Statement
sec_7.py
Function to check palindrome
Source Code
python
# Function to check palindrome
def is_palindrome(text):
# Convert to lowercase for case-insensitive comparison
text = text.lower()
# Reverse the string and compare
if text == text[::-1]:
return True
else:
return False
# Main program
string = input("Enter a string: ")
if is_palindrome(string):
print(f'"{string}" is a Palindrome')
else:
print(f'"{string}" is not a Palindrome')1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16