Skip to content

Instantly share code, notes, and snippets.

@Hwatwasthat
Created February 21, 2018 14:13
Show Gist options
  • Save Hwatwasthat/88df9dd7b758678f3d36bbf9112cfb5f to your computer and use it in GitHub Desktop.
Save Hwatwasthat/88df9dd7b758678f3d36bbf9112cfb5f to your computer and use it in GitHub Desktop.
Palindrome check created by Hwatwasthat - https://repl.it/@Hwatwasthat/Palindrome-check
# Input from console for word to check
word = input("What would you like to check if its a Palindrome?")
#initialise variables
x = 0
reverse_word = ''
# loop over word until all letters are done
for i in word:
# increment counter
x += 1
# extend reverse_word with next letter from word (reversed)
reverse_word += word[len(word)-x]
# check for Palindrome
if reverse_word == word:
print ("its a Palindrome!")
else:
print ("its not a Palindrome")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment