From 2e34921a04304c1320908743a7cf0df64f7c9764 Mon Sep 17 00:00:00 2001 From: Elikem Asudo <92120198+e-c-centric@users.noreply.github.com> Date: Mon, 5 Dec 2022 04:26:30 +0000 Subject: [PATCH] Update palindrome_soln.py Added explanations for the conditions in the is-palindrome function. --- code/palindrome_soln.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/palindrome_soln.py b/code/palindrome_soln.py index b2bb50e..4681e4f 100644 --- a/code/palindrome_soln.py +++ b/code/palindrome_soln.py @@ -30,9 +30,10 @@ def middle(word): def is_palindrome(word): """Returns True if word is a palindrome.""" if len(word) <= 1: - return True + return True #this returns true if the length of the word is 0 or 1 because words might be odd or even-numbered. + #An even-numbered word, after line 37 will have a length of 0. An odd-numbered word will have a length of 1 at the final call of line 37. if first(word) != last(word): - return False + return False #if this condition is met, line 37 will not be run, and the function will terminate. return is_palindrome(middle(word))