Skip to content

Conversation

@PieBerlin
Copy link

Allows symbols and capital letters password

@github-actions
Copy link

👋 @PieBerlin
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.

Copy link
Contributor

@iamwatchdogs iamwatchdogs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PieBerlin, please make the following. changes.

Comment on lines 1 to 73
"""_summary_
implementing password generation program that allows symbols and capital letters if the user wants to include them

Returns:
password
"""



import random


#constants
SMALL_LETTERS="abcdefghijklmnopqrstuvwxyz"
CAPITAL_LETTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SYMBOLS="~!@#$%^&*()_-+={[}]|:;<>?"
MIN_LENGTH=12
MAX_LENGTH=24


#function to generate the password
def dynamic_password(passlength,capitals=False,symbols=False):
characters=SMALL_LETTERS
if capitals:
characters+=CAPITAL_LETTERS
if symbols:
characters+=SYMBOLS
password=""
for i in range(0,passlength):
randomletter=random.choice(characters)
password+=(randomletter)

return password

#Function to take user inputs and validate them
def inputs_validation():
while True:

pass_length=input(f"Enter password length ({MIN_LENGTH}-{MAX_LENGTH}): ")
input_capitals=input("Do we include capitals (y/n): ").strip().lower()
input_symbols=input("Do we include symbols (y/n): ").strip().lower()

# 1. Validate both inputs at once
if input_capitals not in ['y', 'n'] or input_symbols not in ['y', 'n']:
print("Please type 'y' or 'n' for the options.")
continue # Restarts the loop to ask again

#2. convert to booleans
capitals=(input_capitals=='y')
symbols=(input_symbols=='y')

if pass_length.isdigit():
#validate password length
length=int(pass_length)
if 12<=length<=24:
return length,capitals,symbols
else:
print("Please enter password length within the range!!")
continue
print("Password length should be a Number")





def main():
length,capitals,symbols=inputs_validation()
password=dynamic_password(length,capitals,symbols)
print(f"Your Generated Password is : {password}")


if __name__ == "__main__":
main() No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format the code

Suggested change
"""_summary_
implementing password generation program that allows symbols and capital letters if the user wants to include them
Returns:
password
"""
import random
#constants
SMALL_LETTERS="abcdefghijklmnopqrstuvwxyz"
CAPITAL_LETTERS="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SYMBOLS="~!@#$%^&*()_-+={[}]|:;<>?"
MIN_LENGTH=12
MAX_LENGTH=24
#function to generate the password
def dynamic_password(passlength,capitals=False,symbols=False):
characters=SMALL_LETTERS
if capitals:
characters+=CAPITAL_LETTERS
if symbols:
characters+=SYMBOLS
password=""
for i in range(0,passlength):
randomletter=random.choice(characters)
password+=(randomletter)
return password
#Function to take user inputs and validate them
def inputs_validation():
while True:
pass_length=input(f"Enter password length ({MIN_LENGTH}-{MAX_LENGTH}): ")
input_capitals=input("Do we include capitals (y/n): ").strip().lower()
input_symbols=input("Do we include symbols (y/n): ").strip().lower()
# 1. Validate both inputs at once
if input_capitals not in ['y', 'n'] or input_symbols not in ['y', 'n']:
print("Please type 'y' or 'n' for the options.")
continue # Restarts the loop to ask again
#2. convert to booleans
capitals=(input_capitals=='y')
symbols=(input_symbols=='y')
if pass_length.isdigit():
#validate password length
length=int(pass_length)
if 12<=length<=24:
return length,capitals,symbols
else:
print("Please enter password length within the range!!")
continue
print("Password length should be a Number")
def main():
length,capitals,symbols=inputs_validation()
password=dynamic_password(length,capitals,symbols)
print(f"Your Generated Password is : {password}")
if __name__ == "__main__":
main()
"""_summary_
implementing password generation program that allows symbols and
capital letters if the user wants to include them
Returns:
password
"""
import random
# constants
SMALL_LETTERS = "abcdefghijklmnopqrstuvwxyz"
CAPITAL_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SYMBOLS = "~!@#$%^&*()_-+={[}]|:;<>?"
MIN_LENGTH = 12
MAX_LENGTH = 24
# function to generate the password
def dynamic_password(passlength, capitals=False, symbols=False):
characters = SMALL_LETTERS
if capitals:
characters += CAPITAL_LETTERS
if symbols:
characters += SYMBOLS
password = ""
for i in range(0, passlength):
randomletter = random.choice(characters)
password += (randomletter)
return password
# Function to take user inputs and validate them
def inputs_validation():
while True:
pass_length = input(
f"Enter password length ({MIN_LENGTH}-{MAX_LENGTH}): ")
input_capitals = input(
"Do we include capitals (y/n): ").strip().lower()
input_symbols = input("Do we include symbols (y/n): ").strip().lower()
# 1. Validate both inputs at once
if input_capitals not in ['y', 'n'] or input_symbols not in ['y', 'n']:
print("Please type 'y' or 'n' for the options.")
continue # Restarts the loop to ask again
# 2. convert to booleans
capitals = (input_capitals == 'y')
symbols = (input_symbols == 'y')
if pass_length.isdigit():
# validate password length
length = int(pass_length)
if 12 <= length <= 24:
return length, capitals, symbols
else:
print("Please enter password length within the range!!")
continue
print("Password length should be a Number")
def main():
length, capitals, symbols = inputs_validation()
password = dynamic_password(length, capitals, symbols)
print(f"Your Generated Password is : {password}")
if __name__ == "__main__":
main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants