Hi there guys, I’m really struggling with this step. I feel like I’ve done everything 100% right but I must be slipping up somewhere as it wont accept this answer.
The task:
Put your password
variable declaration and the following for
loop inside a while
loop. Use True
as the condition for your new loop.
My code:
import secrets
import string
def generate_password(length, nums, special_chars, uppercase, lowercase):
# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
symbols = string.punctuation
# Combine all characters
all_characters = letters + digits + symbols
while True:
password = ''
# Generate password
for _ in range(length):
password += secrets.choice(all_characters)
return password
# new_password = generate_password(8)
# print(new_password)
The snippet I’m meant to edit:
while True:
password = ''
# Generate password
for _ in range(length):
password += secrets.choice(all_characters)
Thanks for any help!