password-generator 1.0

This commit is contained in:
Philipp
2026-04-21 16:36:18 +02:00
commit 3b29657c5f
4 changed files with 135 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#libraries
import secrets
import string
#create password
def create_password(length: int) -> str:
pool = string.ascii_letters + string.digits + string.punctuation
while True:
password = ''.join(secrets.choice(pool) for _ in range(length))
if any(char.isdigit() for char in password):
return password
#length and check
while True:
try:
length = int(input("Choice the length of the password: "))
if length >= 4:
break
else:
print("the number must be 4 or bigger")
except ValueError:
print("only numbers are allowed")
#output
print("password: ", create_password(length))