Here is an example Python function to generate a password that includes at least one number:
main.py347 chars11 lines
The function generates a random password of a given length, and then checks if it includes at least one digit using a regular expression. If not, it generates a new password and checks again. Once the password satisfies the condition, it is returned.
Example usage:
main.py77 chars5 lines
gistlibby LogSnag