Tell us what’s happening:
hi, pls I don’t know what I’m doing wrong. I tried to assign generate_password(8) to the variable new_password but it didn’t pass
Your code so far
import secrets
import string
def generate_password(length):
# 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
password = ''
# Generate password
for _ in range(length):
password += secrets.choice(all_characters)
return password
# User Editable Region
new_password = generate_password(8)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Challenge Information:
Learn Regular Expressions by Building a Password Generator - Step 20
You should not call this function from within the function.
Additionally, any code in the function (indentation indicates which code is part of the function) after the “return
” statement will never run.
1 Like
Mod Edit: SOLUTION REMOVED
- Make sure you assign the result to
new_password
outside the function definition
1 Like
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
1 Like
okay, I get it now. Thank you
Hi,
I want to ask for help, but I don’t how to go about it since you said I shouldn’t post my full working solution.
If you still need help I would assume your code doesn’t currently work
yes i need help but not for this code, it’s for step 35 of Learn Algorithm Design by Building a Shortest Path Algorithm
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.
The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
Thank you.