Random Password Generation

We will simply use the random library of Python and generate a set of random numbers and random characters and merge them to get a suitable and unique password all the time.

import random, string
# string library for getting all alphabets: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
def random_password_generator():
    # created blank string to store the numeric part of password
    num_part = ''
    # step 1: generate set of random number
    for i in range(4):
        # adding to the string...using randint with range
        num_part = num_part + str(random.randint(1,9))
        # type casted to store number as strings
    # created blank string to store the characters part of password
    string_part =''
    # step 2: generate set of random characters
    for j in range(6):
        # adding to string part using choice to select one
        string_part = string_part + str(random.choice(string.ascii_letters))
    #step 3: symbol part...using choice to select
    symbol_part = random.choice('@#$*&')
    #step 4: add all parts together
    random_password = string_part + symbol_part + num_part
    return random_password

# calling method    
print(random_password_generator())
# fun part: let's print 108 passwords
print('printing 108 random passwords')
for times in range(108):
    print(random_password_generator(),end=' - ')