- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPalindrome.py
More file actions
Latest commit
22 lines (20 loc) · 694 Bytes
/
Copy pathPalindrome.py
File metadata and controls
22 lines (20 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#Vijesh.V @freakoutgames
#checking if a given string is palindrome
#a string or number is palindrome that reads the same forward and backward
# function which return reverse of a string
defpalindrome(string):
j=1
forxinstring:
ifx==string[-j]:
j=j+1
continue
else:
returnFalse
returnTrue
#calling the function to check
str=input("Enter any string: ")
str_without_whitespace= (str.replace(" ", "")).lower() #removing the white spaces and converting it into lowercase
if(palindrome(str_without_whitespace)):
print("The string- %s -is palindrome"%str)
else:
print("The string %s is not palindrome"%str)