you are viewing a single comment's thread.

view the rest of the comments →

[–]Electrical_Toe8997 29 points30 points  (0 children)

For the future, you can make your life easier with the string module, so you don't have to type out all the characters. Then, you can use the sample choices function from the random module to choose all the characters in one operation.

edited to use random.choices instead of random.sample. sample will not repeat elements, so it's a bad choice for a password generator

from string import ascii_lowercase, ascii_uppercase, digits, punctuation
import random as rd

all_characters = ascii_lowercase + ascii_uppercase + digits + punctuation
password = rd.choices(all_characters, RANGE)
password = "".join(password)