in python I am receiving the error
name 'isPalindrome' is not defined
even though I am (I think) clearly defining my function.
class Solution:
def isPalindrome(s) -> bool:
if len(s)%2==0: #even length
for i in range(0,len(s)/2):
if s[i]!=s[len(s)-i]:
return false
else: #odd length
for i in range(0,(len(s)-1)/2):
if s[i]!=s[len(s)-i]:
return false
return true
def longestPalindrome(self, s: str) -> str:
longestString = "";
for i in range(len(s)):
for j in range(0,len(s)):
if(isPalindrome(s[i:j])): #the error is here
if(len(s[i:j]) > len(longestString)):
longestString = s[i:j]
return longestString
ans = isPalindrome("dad") #this does not give warning 'undefined'
I am proficient in Java, C++, but just starting to learn python3. I am forcing myself to learn it by doing leetcode in Python. Any help would be appreciated