diff --git a/src/mnemonic/mnemonic.py b/src/mnemonic/mnemonic.py index caa4ffb..3fdb687 100644 --- a/src/mnemonic/mnemonic.py +++ b/src/mnemonic/mnemonic.py @@ -165,8 +165,9 @@ def to_entropy(self, words: list[str] | str) -> bytearray: wordindex = 0 for word in words: # Find the words index in the wordlist - ndx = self.wordlist.index(self.normalize_string(word)) - if ndx < 0: + try: + ndx = self.wordlist.index(self.normalize_string(word)) + except ValueError: raise LookupError('Unable to find "%s" in word list.' % word) # Set the next 11 bits to the value of the index. for ii in range(11):