Question: i need help fixing this code: Im not getting the right output or any at all. import string # DO NOT EDIT THIS LINE import
i need help fixing this code: Im not getting the right output or any at all. import string # DO NOT EDIT THIS LINE
import random # DO NOT EDIT THIS LINE
# PART A
#
# You will use your code from Problem to create a new function with the
# following signature:
#
# generatePasswordlength uppercase, lowercase, numeric
#
# This method will generate a password of a given length using the user's
# choice of uppercase, lowercase, and numeric characters and
# return the new password. You can accomplish this by creating a variable
# to hold a new password and creating a loop to randomly select a character
# and add it to the new variable, looping until the length requirement
# is met. Note: you can also use the joinfor syntax as an alternative
#
# This method will then return the new password
def generatePasswordlength uppercase, lowercase, numeric:
chars
if uppercase:
chars string.asciiuppercase
if lowercase:
chars string.asciilowercase
if numeric:
chars string.digits
if not chars:
return
password joinrandomchoicechars for in rangelength
return password
def main: # DO NOT EDIT THIS LINE
printWelcome to the Password Generator"
# PART B
#
# You will ask the user if they want to include uppercase, lowercase,
# and numeric characters as part of the output character set.
#
# You will do this by asking the following questions:
#
# How long do you want your password to be
# Do you want to include UPPERCASE characters? YES, NO
# Do you want to include lowercase characters? YES, NO
# Do you want to include numeric characters? YES, NO
#
# Save each response into the respective variables:
#
# lengthresponse
# uppercaseresponse
# lowercaseresponse
# numericresponse
#
# Only ask the four questions use four input statements Do not include
# any more print statements or input statements.
#
# Once you gather this information, pass it to the generatePassword function
# and display the result.
lengthresponse intinputHow long do you want your password to be
uppercaseresponse intinputDo you want to include UPPERCASE characters? YES, NO
lowercaseresponse intinputDo you want to include lowercase characters? YES, NO
numericresponse intinputDo you want to include numeric characters? YES, NO
password generatePassword
lengthresponse,
booluppercaseresponse
boollowercaseresponse
boolnumericresponse
if password:
printgenerated password:", password
else:
printNo valid character set selected for passwprd generation."
return # DO NOT EDIT THIS LINE
if namemain: # DO NOT EDIT THIS LINE
main# DO NOT EDIT THIS LINE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
