From e24740d3e7e188544890138d05fe7813e733797e Mon Sep 17 00:00:00 2001 From: Alex Chirino Date: Fri, 24 Jul 2020 19:11:04 -0500 Subject: [PATCH] Complete the challenge 02 of python --- src/main.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index fc9a525..fc76fa1 100644 --- a/src/main.py +++ b/src/main.py @@ -1,11 +1,35 @@ # Resolve the problem!! import string +import random SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~') - def generate_password(): # Start coding here + passwd_len = random.randint(8,16) + + UPPER_CASE = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z' + UPPER_CASE = UPPER_CASE.split() + + LOWER_CASE = list(map(str.lower, UPPER_CASE)) + + NUMBERS = list(range(10)) + NUMBERS = list(map(str, NUMBERS)) + + SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~') + + psswd = '' + UPPER_CASE = random.choices(UPPER_CASE, k=passwd_len//4) + LOWER_CASE = random.choices(LOWER_CASE, k=passwd_len//4) + NUMBERS = random.choices(NUMBERS, k=passwd_len//4) + SYMBOLS = random.choices(SYMBOLS, k=passwd_len//4) + + psswd += ''.join(UPPER_CASE) + psswd += ''.join(LOWER_CASE) + psswd += ''.join(NUMBERS) + psswd += ''.join(SYMBOLS) + + return psswd def validate(password):