Skip to content

Instantly share code, notes, and snippets.

@ppeuchin
Created September 3, 2021 16:20
Show Gist options
  • Save ppeuchin/3ca1f3b9601862dc537cfa0db1ed0c82 to your computer and use it in GitHub Desktop.
Save ppeuchin/3ca1f3b9601862dc537cfa0db1ed0c82 to your computer and use it in GitHub Desktop.
A program that reads a string from the user and uses a loop to determines whether or not it is a palindrome.
# A string is a palindrome if it is identical forward and backward.
palindrome = input("Enter a string: ")
reversed_text = ""
for i in range(-1, -(len(palindrome) + 1), -1):
reversed_text = reversed_text + palindrome[i]
if palindrome == reversed_text:
print(palindrome, "is a palindrome")
else:
print(palindrome, "is not a palindrome")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment