Forum
>>
Programmazione Python
>>
Database
>>
Python Password Generator Program Error
Pagina: 1
Esegui il login per scrivere una risposta.
Pagina: 1
Scritto da Gulshan Negi |
2023-04-15 06:33:46 - Python Password Generator Program Error
|
Hello this is Gulshan Negi
Well, I am writing a program for password generation but it shows some error at the time of execution. Can anyone suggest what I am missing in below source code: Source Code: import secrets import string def create_pw(pw_length=12): letters = string.ascii_letters digits = string.digits special_chars = string.punctuation alphabet = letters + digits + special_chars pwd = ''" pw_strong = False: while not pw_strong: pwd = ''" for i in range(pw_length): pwd += ''.join(secrets.choice(alphabet)) if (any(char in special_chars for char in pwd) and sum(char in digits for char in pwd) >= 2): pw_strong = True return pwd if __name__ == '__main__': print(create_pw()) Can anyone give their suggestions on this what I am missing here. I also checked and take reference from here but I don't know what is wrong with coding. Thanks |
|
Scritto da nuzzopippo |
2023-04-15 08:57:18 - Re: Python Password Generator Program Error
|
He doesn't speak English, this text is produced by google translate
For future code examples format the text using the appropriate button available in the post editor. Also provide the traceback received for evaluation. I interpreted your code and found two possible errors introduced by the editor: pwd = ''"and an obvious syntax error pw_strong = False:corrected these imperfections, the code thus implemented import secrets import string def create_pw(pw_length=12): letters = string.ascii_letters digits = string.digits special_chars = string.punctuation alphabet = letters + digits + special_chars pwd = "" pw_strong = False while not pw_strong: pwd = "" for i in range(pw_length): pwd += ''.join(secrets.choice(alphabet)) if (any(char in special_chars for char in pwd) and sum(char in digits for char in pwd) >= 2): pw_strong = True return pwd if __name__ == '__main__': print(create_pw())seems to work fine, this is the output in an IDLE shell Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license()" for more information. ============ RESTART: /home/nuzzopippo/src/posts/Gulshan Negi /suo.py =========== =1uh!5RLrl>2let me know if it fixes, bye Fatti non foste a viver come bruti... |
|
Scritto da Gulshan Negi |
2023-04-15 13:19:30 - Re: Python Password Generator Program Error
|
Pagina: 1
Esegui il login per scrivere una risposta.