MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / alternative_password_generator

Function alternative_password_generator

other/password.py:28–47  ·  view source on GitHub ↗
(chars_incl: str, i: int)

Source from the content-addressed store, hash-verified

26# chars_incl= characters that must be in password
27# i= how many letters or characters the password length will be
28def alternative_password_generator(chars_incl: str, i: int) -> str:
29 # Password Generator = full boot with random_number, random_letters, and
30 # random_character FUNCTIONS
31 # Put your code here...
32 i -= len(chars_incl)
33 quotient = i // 3
34 remainder = i % 3
35 # chars = chars_incl + random_letters(ascii_letters, i / 3 + remainder) +
36 # random_number(digits, i / 3) + random_characters(punctuation, i / 3)
37 chars = (
38 chars_incl
39 + random(ascii_letters, quotient + remainder)
40 + random(digits, quotient)
41 + random(punctuation, quotient)
42 )
43 list_of_chars = list(chars)
44 shuffle(list_of_chars)
45 return "".join(list_of_chars)
46
47 # random is a generalised function for letters, characters and numbers
48
49
50def random(chars_incl: str, i: int) -> str:

Callers 1

mainFunction · 0.85

Calls 1

randomFunction · 0.85

Tested by

no test coverage detected