## solution 1: fast enough response, simple function, fail fast
from time import clock
def isanaword(k,s):
    """ goes through the letters of second word (s) and returns it
        if first word (k) contains exactly same letters in same number
    for c in s:
        pos = k.find(c)
        if pos==-1: return "" ## letter not contained in first one found
        k = k[:pos]+k[pos+1:] ## drop the letter in found position pos by slicing
    if not k: return s ## if all letters used, full anagram

if __name__=="__main__":
    print('To quit enter empty line')
    inputword=' '
    while inputword:
        inputword=raw_input('Give word: ')
        if inputword:
            for wd in [w.rstrip()
                       for w in open('words.txt')
                       if (len(w) == len(inputword)+1 ## newline longer
                           and isanaword(w.rstrip(),inputword))]:
                print wd,
            print 'Took %i ms'%((clock()-t)*1000)

Recommended Answers

All 7 Replies

What operating system are you using?

commented: win7 +0

I'm new at coding, how would I implement that Windows clipboard functionality to the script?

If you don't have Python34 get the appropriate installer version.
After that simply use the functions supplied by the snippet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.