Monday, March 26, 2012

exercise 8.8 - is_reverse


"""======================
exercise 8.8
======================"""
def is_reverse(word1, word2):
    if len(word1) != len(word2):
        return False
        
    i = 0
    j = len(word2)-1
    
    while j >= 0:
        print i, j,
        print word1[i], word2[j]
        if word1[i] != word2[j]:
            return False
        i = i+1
        j = j-1
        
    return True
    
print is_reverse('stop','pots')

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.