password-generator 1.0
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
#imports
|
||||
|
||||
import string
|
||||
import secrets
|
||||
|
||||
#create password
|
||||
|
||||
def create_password(length: int) -> str:
|
||||
pool = string.digits
|
||||
return ''.join(secrets.choice(pool) for _ in range(length))
|
||||
|
||||
#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 biggger")
|
||||
|
||||
except ValueError:
|
||||
print("only numbers are allowed")
|
||||
|
||||
#output
|
||||
print("password: ", create_password(length))
|
||||
Reference in New Issue
Block a user