From c65743ec02ef9543203902f7c372dd6310daf3a7 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 9 Aug 2021 08:33:02 -0700 Subject: [PATCH] Use random.choices instead of random.choice in a loop. --- voussoirkit/passwordy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voussoirkit/passwordy.py b/voussoirkit/passwordy.py index afc9343..c310870 100644 --- a/voussoirkit/passwordy.py +++ b/voussoirkit/passwordy.py @@ -116,7 +116,7 @@ def make_password(length=None, passtype='standard'): random.shuffle(alphabet) password += alphabet.pop(0) else: - password = ''.join([random.choice(alphabet) for x in range(length)]) + password = ''.join(random.choices(alphabet, k=length)) return password def make_sentence(length=None, joiner=' '): @@ -127,7 +127,7 @@ def make_sentence(length=None, joiner=' '): import dictionary.common as common if length is None: length = DEFAULT_LENGTH - words = [random.choice(common.words) for x in range(length)] + words = random.choices(common.words, k=length) words = [w.replace(' ', joiner) for w in words] result = joiner.join(words) return result