Skip to main content
edited tags
Link
Reinderien
  • 71.2k
  • 5
  • 76
  • 257
Rollback to Revision 2
Source Link
pacmaninbw
  • 26.2k
  • 13
  • 47
  • 114

Python \ random password generatorgeneration code

I have written a Pythonpython program for random password generation, and as a newbie I would like my code to be reviewed by professionals to seeand if they have any suggestions to improve it.

import string 
import random
 
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))

#...................................................
password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break
 
p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    

Python random password generator

I have written a Python program for random password generation, and as a newbie I would like my code to be reviewed by professionals to see if they have any suggestions to improve it.

import string 
import random
 
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))


password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break
 
p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    

Python \ random password generation code

I have written a python program for random password generation and as a newbie I would like my code to be reviewed by professionals and if they have any suggestions to improve it.

import string 
import random
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))

#...................................................
password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break
p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    
Fixed grammar and code formatting
Source Link

Python \ random password generation codegenerator

I have written a pythonPython program for random password generation, and as a newbie I would like my code to be reviewed by professionals andto see if they have any suggestions to improve it.

import string 
import random 

letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))

#...................................................
password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break 

p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    

Python \ random password generation code

I have written a python program for random password generation and as a newbie I would like my code to be reviewed by professionals and if they have any suggestions to improve it.

import string 
import random
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))

#...................................................
password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break
p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    

Python random password generator

I have written a Python program for random password generation, and as a newbie I would like my code to be reviewed by professionals to see if they have any suggestions to improve it.

import string 
import random 

letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
letters_list = list(letters)
digits_list = list(digits)
special_list = list(special_chars)
many_letter = int(input(f"how many letter ? \n")) 
many_digit = int(input(f"how many digits ? \n"))
many_special = int(input(f"how many special chars ? \n"))


password = []
finalpassword = []
counter_l = 0
for l in letters_list :
    password.append(random.choice(letters_list))
    counter_l += 1
    if counter_l == many_letter :
        break

counter_d = 0
for d in digits_list :
    password.append(random.choice(digits_list))
    counter_d += 1
    if counter_d == many_digit :
        break

counter_s = 0
for s in special_list :
    password.append(random.choice(special_list))
    counter_s += 1
    if counter_s == many_special :
        break 

p_counter = 0
for p in password :
   finalpassword.append(random.choice(password))
   p_counter += 1 
   if p_counter == len(password) : 
       break
   
print("".join(finalpassword))
     
    
Became Hot Network Question
add tag ; remove Thanks - say thanks by voting - see https://codereview.stackexchange.com/help/behavior and https://codereview.stackexchange.com/help/why-vote
Source Link
Loading
Source Link
M.alizadeh
  • 103
  • 1
  • 5
Loading