Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #CODE GENERATOR
- #4th - start endofaugust , three days+-
- import random
- import secrets
- import string
- import sys
- def random_alnum(letter_count, digit_count):
- str1 = ''.join((random.choice(string.ascii_letters) for x in range(letter_count)))
- str1 += ''.join((random.choice(string.digits) for x in range(digit_count)))
- sam_list = list(str1)
- random.shuffle(sam_list)
- final_string = ''.join(sam_list)
- return final_string
- def random_alnpu(letter_count, digit_count, punc_count):
- str1 = ''.join((random.choice(string.ascii_letters) for x in range(letter_count)))
- str1 += ''.join((random.choice(string.digits) for x in range(digit_count)))
- str1 += ''.join((random.choice(string.punctuation) for x in range(punc_count)))
- sam_list = list(str1)
- random.shuffle(sam_list)
- final_string = ''.join(sam_list)
- return final_string
- while True:
- print("-------------------")
- print("Code Generator (or Password Generator?)")
- print("-------------------")
- code = ["1. Random Letters" ,"2. Random Numbers", "3. Random Numbers + Letters" , "4. Random Numbers + Letters + Punctuations"]
- for options in code:
- print(options)
- code = input("Please type the number of one of the option above! ")
- cd = int(code)
- if code == "1" :
- print()
- rep = str(input("May have repeatable characters? : "))
- if rep == "yes" or rep == "Yes":
- alpha=int(input("How many letters? : "))
- rdmalpha = ''.join(secrets.choice(string.ascii_letters) for x in range(alpha))
- print ("Here's your code: " , str(rdmalpha))
- else :
- def norepeat(length):
- letters = string.ascii_lowercase
- result1 = ''.join((random.sample(letters, length)))
- print ("Here's your code: " , result1)
- num1=int(input("How many letters? : "))
- norepeat(num1)
- elif int(code == "2") :
- print()
- number=int(input("How many numbers? : "))
- rdmnum = ''.join(secrets.choice(string.digits) for x in range(number))
- print("Here's your code: " , str(rdmnum))
- elif int(code == "3") :
- print()
- let = int(input("How many letters? : "))
- num = int(input("How many numbers? : "))
- print("Here's your code: " , random_alnum(let, num))
- elif int(code == "4") :
- print()
- let1 = int(input("How many letters? : "))
- num1 = int(input("How many numbers? : "))
- punc = int(input("How many punctuations? : "))
- print("Here's your code: " , random_alnpu(let1, num1, punc))
- print()
- again= input("Would you like to try again? : ")
- if again == "Yes" or again == "yes":
- continue
- else :
- print("Thanks for using the code generator!")
- sys.exit()
- #Talice ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement