0% found this document useful (0 votes)
20 views1 page

Final Quest 2

The document describes a Python script that generates a random password of a user-specified length by randomly selecting characters from a predefined list and concatenating them together. The script imports the random module, defines a main function, gets the desired password length from the user, creates a character list to choose from, randomly selects characters and adds them to a final password string which is printed out at the end.

Uploaded by

Miss Invisible
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Final Quest 2

The document describes a Python script that generates a random password of a user-specified length by randomly selecting characters from a predefined list and concatenating them together. The script imports the random module, defines a main function, gets the desired password length from the user, creates a character list to choose from, randomly selects characters and adds them to a final password string which is printed out at the end.

Uploaded by

Miss Invisible
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#bring in random module

import random

#define main
def main():

#declare variables
passLength = 0.0
finalPass = ''
characterChoice = ''

passLength = int(input('Please enter a desired length for your password: '))

#create list to randomly pick from


CHARLIST =
['a','A','b','B','c','C','d','D','f','F','g','G','h','H','i','I','j','J',

'k','K','l','L','m','M','n','N','o','O','p','P','q','Q','r','R','s','S',

't','T','u','U','v','V','w','W','x','X','y','Y','z','Z','0','1','2','3',

'4','5','6','7','8','9',',','.','/','<','>','?',';',':','[',']','|','{',

'}','~','!','@','#','#','$','%','^','&','*','(',')','-','_','=','+']

for index in range(passLength):


#pick from list of characters
characterChoice = random.choice(CHARLIST)
#test - characterChoice
#combine random picks
finalPass += characterChoice
#test - print(finalPass)

print('Your password is:',finalPass)


#---------------------------
#call main
if __name__ == '__main__':
main()

You might also like