diff --git a/src/main.py b/src/main.py index 86f3f66..a7735ef 100644 --- a/src/main.py +++ b/src/main.py @@ -15,8 +15,27 @@ def is_palindrome(palindrome): # Start coding here - pass + # I will develop this function with loops, it's too easy to do it with slices + #String preparation: to lowercase and delete the spaces + palindrome = palindrome.lower() + palindrome = palindrome.replace(' ', '') + + #loop through each character of the string, comparing the first with the last, and so on. + str_len = len(palindrome) + + i = 0 + j = str_len - 1 + + while i < str_len: + if palindrome[i] != palindrome[j]: + return False + i += 1 + j -= 1 + + return True + + def validate(): for palindrome in PALINDROMES: if not is_palindrome(palindrome):