Create an algorithm to detect a palindrome string in Python.
String str = "madam";
def isPalindrome(str):
  left, right = 0, len(str) - 1
  while right >= left:
    if not str[left] == str[right]:
      return False
    left += 1
    right -= 1
  return True