Created
February 6, 2017 22:56
-
-
Save shamikalashawn/67c536aa8302a3955336f6b83920169a to your computer and use it in GitHub Desktop.
Two words are compared. If one word is the reverse of the other, the function returns "True". Otherwise the function returns "False".
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
def is_reverse(word1, word2): | |
if len(word1) != len(word2): | |
return False | |
i = 0 | |
j = len(word2)-1 | |
while j > -1: | |
print (i, j) #print here | |
if word1[i] != word2[j]: | |
return False | |
i += 1 | |
j -= 1 | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment