Update xkcd_password.py
authorRahul Goswami <redacted>
Wed, 28 Feb 2018 20:19:14 +0000 (20:19 +0000)
committerGitHub <redacted>
Wed, 28 Feb 2018 20:19:14 +0000 (20:19 +0000)
xkcdpass/xkcd_password.py

index 193bf5231558fac6c8401b1649a3c4a3e61772e4..abca96ef935f22de2db7e5939bc73ee44124a4f6 100755 (executable)
@@ -147,7 +147,7 @@ def wordlist_to_worddict(wordlist):
 
     # Maybe should be a defaultdict, but this reduces dependencies
     for word in wordlist:
-        if word[0] not in worddict:
+        if word[0] not in worddict:              # replaced try-catch with if statement
             worddict[word[0]] = []
         worddict[word[0]].append(word)
         
@@ -205,9 +205,9 @@ def choose_words(wordlist, numwords):
     assert len(wordlist) > 0
    
     if len(wordlist) >= numwords:
-        return rng().sample(wordlist, numwords)  # ensures no duplicates
+        return random.sample(wordlist, numwords)  # ensures no duplicates
     else:
-      return rng().choices(wordlist, numwords)  # allows duplicates if wordlist is small
+      return random.choices(wordlist, numwords)  # allows duplicates if wordlist is small
 
 
 def try_input(prompt, validate):
git clone https://git.99rst.org/PROJECT