Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.py #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 32 additions & 29 deletions day05/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,40 @@
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']

print("Welcome to the PyPassword Generator!")
nr_letters= (input("How many letters would you like in your password?\n"))
nr_symbols = (input(f"How many symbols would you like?\n"))
nr_numbers = (input(f"How many numbers would you like?\n"))

if not nr_letters.isdigit() or not nr_symbols.isdigit() or not nr_numbers.isdigit():
print("Invalid value, enter a number instead.")
else:
password = []

random_letter = random.randint(0, 51)
for i in range(0, int(nr_letters)):
print("\nWelcome to the PyPassword Generator\n!")

while True:
nr_letters= (input("How many letters would you like in your password?\n"))
nr_symbols = (input(f"How many symbols would you like?\n"))
nr_numbers = (input(f"How many numbers would you like?\n"))

if not nr_letters.isdigit() or not nr_symbols.isdigit() or not nr_numbers.isdigit():
print("Invalid value, enter a number instead.")
else:
password = []

random_letter = random.randint(0, 51)
password.append(letters[random_letter])
for i in range(0, int(nr_letters)):
random_letter = random.randint(0, 51)
password.append(letters[random_letter])

random_number = random.randint(0,9)
for i in range(0, int(nr_numbers)):
random_number = random.randint(0,9)
password.append(numbers[random_number])
for i in range(0, int(nr_numbers)):
random_number = random.randint(0,9)
password.append(numbers[random_number])

random_symbol = random.randint(0,8)
for i in range(0, int(nr_symbols)):
random_symbol = random.randint(0,8)
password.append(symbols[random_symbol])

random.shuffle(password)
print(f"Here is your password: {''.join(password)}")

if len(password) <= 6:
print("Your password is weak, try to include at least 8 characters for a stronger password.")
elif len(password) == 7:
print("Your password is medium, try to include at least 8 characters for a stronger password.")
else:
print("Your password is strong.")
for i in range(0, int(nr_symbols)):
random_symbol = random.randint(0,8)
password.append(symbols[random_symbol])

random.shuffle(password)
print(f"Here is your password: {''.join(password)}")

if len(password) <= 6:
print("Your password is weak, try to include at least 8 characters for a stronger password.")
elif len(password) == 7:
print("Your password is medium, try to include at least 8 characters for a stronger password.")
else:
print("Your password is strong.")
exit()