forked from AllenDowney/ThinkPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse_pair.py
More file actions
30 lines (19 loc) · 607 Bytes
/
Copy pathreverse_pair.py
File metadata and controls
30 lines (19 loc) · 607 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""This module contains code from
Think Python by Allen B. Downey
http://thinkpython.com
Copyright 2012 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from inlist import *
def reverse_pair(word_list, word):
"""Checks whether a reversed word appears in word_list.
word_list: list of strings
word: string
"""
rev_word = word[::-1]
return in_bisect(word_list, rev_word)
if __name__ == '__main__':
word_list = make_word_list()
for word in word_list:
if reverse_pair(word_list, word):
print word, word[::-1]