Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down