A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Generate a random Password which meets the following conditions using python programming
Q:

Generate a random Password which meets the following conditions using python programming

0

Generate a random Password which meets the following conditions

  • Password length must be 10 characters long.
  • It must contain at least 2 upper case letters, 1 digit, and 1 special symbol.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import random
import string

def randomPassword():
    randomSource = string.ascii_letters + string.digits + string.punctuation
    password = random.sample(randomSource, 6)
    password += random.sample(string.ascii_uppercase, 2)
    password += random.choice(string.digits)
    password += random.choice(string.punctuation)

    passwordList = list(password)
    random.SystemRandom().shuffle(passwordList)
    password = ''.join(passwordList)
    return password

print ("Password is ", randomPassword())

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now