Last active
February 22, 2018 15:37
-
-
Save Hwatwasthat/37769fe14c1629fafb327bc234f9d219 to your computer and use it in GitHub Desktop.
PasswordGen(not perfect, some characters not allowed) created by Hwatwasthat - https://repl.it/@Hwatwasthat/PasswordGennot-perfect-some-characters-not-allowed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string, random | |
from collections import OrderedDict | |
from itertools import count | |
# creating numerically linked dictionaries to pull characters from | |
lower = OrderedDict(zip(count(1), string.ascii_lowercase)) | |
upper = OrderedDict(zip(count(27), string.ascii_uppercase)) | |
symbols = OrderedDict(zip(count(53), (string.punctuation))) | |
length = int(input("How many characters would you like in your password?")) | |
i = 0 | |
password = [] | |
# generates a length password | |
while i < length: | |
ran = random.randint(1, 93) | |
if ran < 27: | |
password.append(lower[ran]) | |
elif ran < 53: | |
password.append(upper[ran]) | |
elif ran < 85: | |
password.append(symbols[ran]) | |
else: | |
password.append(str(random.randint(0, 9))) | |
i += 1 | |
print (''.join(password)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment