Created
September 3, 2021 16:20
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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