We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7a67509 commit 629b914Copy full SHA for 629b914
String_Palindrome.py
@@ -1,15 +1,15 @@
1
# Program to check if a string is palindrome or not
2
3
-my_str = 'aIbohPhoBiA'
+my_str = input().strip()
4
5
# make it suitable for caseless comparison
6
my_str = my_str.casefold()
7
8
# reverse the string
9
-rev_str = reversed(my_str)
+rev_str = my_str[::-1]
10
11
# check if the string is equal to its reverse
12
-if list(my_str) == list(rev_str):
+if my_str == rev_str:
13
print("The string is a palindrome.")
14
else:
15
print("The string is not a palindrome.")
0 commit comments