2021年3月27日星期六

Python Function to determine if string is Palindrome

def main():  string = input('> ')  while string != 'quit()':      if isPalindrome(string):          print ('palindrome')      else:          print ('not a palindrome')      string = input('> ')      def isPalindrome(s):      return s == s[::-1]          if __name__ == '__main__':      main()  

The above code will return false when I run isPalindrome(44) or any palindrome for that matter.

https://stackoverflow.com/questions/66838255/python-function-to-determine-if-string-is-palindrome March 28, 2021 at 11:55AM

没有评论:

发表评论