I was trying to import a palindrome function from a previously made code. Initially the palindrome code was working properly, but after I imported it, it is not showing correct answer.
import re
def check(string):
if (string==string[::-1]):
print ("{} is palindorme".format(string))
else:
print ("{} is not palindorme".format(string))
def palindrome(text):
c=re.sub('["?",",",".","/","@","#","%","&","*","!"," "]',"",text)
check(c)
This is the function I am using:
from pal_func import palindrome
f=open("C:\\Users\\hp\\Desktop\\test file.txt",'r')
c=f.readline().lower()
print(c)
palindrome(c)
Output should be:
was it a cat i saw?
wasitacatisaw is palindrome
But it is showing:
was it a cat i saw?
wasitacatisaw
is not palindorme