Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create password_generator.py #1784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions password_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import string, random

if __name__ == '__main__':
s1 = string.ascii_lowercase
s2 = string.ascii_uppercase
s3 = string.digits
s4 = string.punctuation

while True:
a = input("Enter password length\n") # handle gibberish(anything is entered except int)
b = a.isdigit()
if b==True:
plen= int(a)
break
else:
print("Invalid value! Please enter the valid value")

s = []
s.extend(list(s1))
s.extend(list(s2))
s.extend(list(s3))
s.extend(list(s4))

random.shuffle(s)

print("".join(s[0:plen]))
# The string whose method is called is inserted in between each given string.
# The result is returned as a new string.
# Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'