Here is my code:
def detLoser(frag, a):
word = frag + a
if word in wordlist:
lost = True
else:
for words in wordlist:
if words[:len(word) == word:
return #I want this to break out.
else:
lost = True
Where I have a return, I've tried putting in both return and break and both give me errors. Both give me the following error: SyntaxError: invalid syntax. Any Ideas? What is the best way to handle this?
You've omitted the ]
from the list slice. But what is the code trying to achieve, anyway?
foo[ : len( foo ) ] == foo
always!
I assume this isn't the complete code -- if so, where is wordlist
defined? (is it a list? -- it's much faster to test containment for a set.)