python - Look for a string object from a list in another list -


i doing little project in program unscrambles string , finds every possible combination of it.

i have 2 lists; combolist , wordlist. combolist holds every combination of word; example, combolist 'abc' is:

['abc','acb','bac','bca','cab','cba'] 

(only 'cab' real word)

wordlist holds 56,000 words imported text file. these found in english dictionary , sorted length , alphabetically.

isrealword(combolist,wordlist) function test words in combolist real checking if in wordlist. here's code:

def isrealword(combolist, wordlist):     print 'debug 1'     combo in combolist:         print 'debug 2'         if combo in wordlist:            print 'debug 3'            print combo            listofactualwords.append(combo)     print 'debug 4' 

this output:

run c:/users/uzair/documents/programming/python/unscramble.py please give string of scrambled letters unscramble: abc  ['a', 'b', 'c']  ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']  loading word list...  55909 words loaded  debug 1  debug 2  debug 2  debug 2  debug 2  debug 2  debug 2  debug 4  [] 

why if combo in wordlist not returning true , how fix it?

i think problem here compare 2 strings same letters mixed lower/upper cases.
see if i'm correct try convert word in wordlist upper-case , in isrealword compare upper-case word (just sure) follows:

uppercasewordlist = [word.upper() word in wordlist] ... def isrealword(combolist, wordlist):     combo.upper() in combolist:         if combo in wordlist:            print combo            listofactualwords.append(combo) 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -