Hi Don I'm a beginner in Python Programming.
I'm using python 3. I wrote a program that checks whether given two words are reverse pair or not and outputs TRUE/FALSE. *def reverse_pair(a,b):* * return list(a)==list(reversed(list(b)))* * * * * But how to write a program that finds all the reverse pairs in the given word list, eg: how to find the reverse pair words in a list of 20 words. And that to how to access those list of words form a URL. Because with the above code we can only find out whether the given 2 words are reverse pair or not, that's it. I'm thinking of using the below code which is written for Python 2.7. Code: 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] On Fri, Apr 19, 2013 at 2:05 PM, Don Jennings <dfjenni...@gmail.com> wrote: > > On Apr 19, 2013, at 4:56 PM, Chetan Sai wrote: > > > Here is my question: > > > > "Two words are a “reverse pair” if each is the reverse of the other. > Write a program that finds all the reverse pairs in the word list. The word > list can be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt" > > Really, that's not a question, but we are happy to answer questions :>) > Oh, there's your question in the subject line. What have you tried thus > far? Have you given any thought to what steps you might have to take to > solve this task? > > Take care, > Don > > -- Thanks & Regards Sai Chetan Pothula 408-203-3323 On Fri, Apr 19, 2013 at 2:05 PM, Don Jennings <dfjenni...@gmail.com> wrote: > > On Apr 19, 2013, at 4:56 PM, Chetan Sai wrote: > > > Here is my question: > > > > "Two words are a “reverse pair” if each is the reverse of the other. > Write a program that finds all the reverse pairs in the word list. The word > list can be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt" > > Really, that's not a question, but we are happy to answer questions :>) > Oh, there's your question in the subject line. What have you tried thus > far? Have you given any thought to what steps you might have to take to > solve this task? > > Take care, > Don > > -- Thanks & Regards Sai Chetan Pothula 408-203-3323
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor