### The following function reverses the given phrase and checks it against the original # palindrome1: string -> boolean def palindrome1(phrase): """checks if the given phrase is a palindrome or not. The phrase should not contain any spaces or punctuation marks.""" reversePhrase = "" for position in range(len(phrase) - 1, 0, -1): reversePhrase = reversePhrase + phrase[position] return reversePhrase == phrase ### The following function checks character by character to determine if the phrase is a palindrome # palindrome2: string -> boolean def palindrome2(phrase): """checks if the given phrase is a palindrome or not. The phrase should not contain any spaces or punctuation marks.""" isPalindrome = True for position in range(len(phrase) // 2): isPalindrome = isPalindrome and (phrase[position] == phrase[-position - 1]) return isPalindrome ### The following function improves palindrome2 ### so that it does not check every character. ### Once it finds there is a difference in characters, ### it should be able to stop and return False # palindrome3: string -> boolean def palindrome3(phrase): """checks if the given phrase is a palindrome or not. The phrase should not contain any spaces or punctuation marks.""" length = len(phrase) for index in range(length // 2): if (phrase[indeex] != phrase[length - 1 - index]): return False return True # palindrome3: string -> boolean def palindrome3(phrase): """checks if the given phrase is a palindrome or not. The phrase should not contain any spaces or punctuation marks.""" for position in range(len(phrase) // 2): if (phrase[position] != phrase[-position - 1]): return False return True