Skip to content

Instantly share code, notes, and snippets.

@joan0fsnark
Created June 9, 2021 02:57
Show Gist options
  • Save joan0fsnark/d0ec5e2670583b9abc34bebf7b2f58b7 to your computer and use it in GitHub Desktop.
Save joan0fsnark/d0ec5e2670583b9abc34bebf7b2f58b7 to your computer and use it in GitHub Desktop.
Find palindromes in list of words
list = ['radar', 'racecar', 'grumble']
for word in list:
palindrome = True
start = 0
end = len(word) - 1 # pos of last letter
while start < end:
if word[start] != word[end]:
print(f"Not a palindrome: {word}")
palindrome = False
break
start = start + 1
end = end - 1
if palindrome:
print(f"Palindrome: {word}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment