'Password generator using sample methods, importing random
import random
#Creating a list with special characters, letters and numbers.
list_of_characters=[1,2,3,"V","S","A","<","$",5,7,"&","^","*","#",4,5,6,7]
list_of_sc=["*","&","^","$","#"]
list_of_digits=[1,2,3,4,5,6,7]
list_of_letters=["V","S","A"]
#Asking the person how long does their password wants to be.
length=int(input("How many characters does your password want to have ? : "))
#Asking the person how many letters ,digits,numbers wants their password to have.
digits=int(input("How many numbers does your password want to have ? : "))
letter=int(input("How many letter does your password want to have "))
special_characters=int(input("How many special carachters does your password want to have "))
while letter+special_characters+letter > length:
print("Please you exceed the number")
length=int(input("How many characters does your password want to have ? : "))
digits=int(input("How many numbers does your password want to have ? : "))
letter=int(input("How many letter does your password want to have "))
special_characters=int(input("How many special carachters does your password want to have "))
else:
print("Good")
#Creating a function where you iterate on the list.
#Creating a newpassword that takes random numbers,letter,sc from the list.
def password():
best_password=[]
new_password=[]
new_password_specialcharacters=[]
new_password_digits=[]
new_password_letters=[]
#Adding the digigs ,letters and sc in the new_pass
new_password_specialcharacters=random.sample(list_of_sc , special_characters)
new_password_digits=random.sample(list_of_digits, digits)
new_password_letters=random.sample(list_of_letters, letter)
new_password=new_password_specialcharacters + new_password_digits+new_password_letters
best_password=random.sample(new_password, length)
print(best_password)
password()
" Hey! This is one of my first projects that I made and I wanted to know what is your opinion about it. How it is written ,or if there are some improvement to made. I am sure that there are more ways to do this type of project but what do you think. And if you have some tips for beginners like me . What should I try to do more . Thank you for your patience"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
