Created
February 22, 2020 20:50
-
-
Save mayankdawar/e53d3b0b2ac830d5be00064de76255a0 to your computer and use it in GitHub Desktop.
A palindrome is a phrase that, if reversed, would read the exact same. Write code that checks if p_phrase is a palindrome by reversing it and then checking if the reversed version is equal to the original. Assign the reversed version of p_phrase to the variable r_phrase so that we can check your work.
This file contains 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
p_phrase = "was it a car or a cat I saw" | |
r_phrase = p_phrase[::-1] |
p_phrase = "was it a car or a cat I saw"
phrase = []
for letter in p_phrase:
phrase.append(letter)
phrase.reverse()
r_phrase= ''
r_phrase = "".join(phrase)
print(r_phrase)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you