diff --git a/Applications/Random Password Generator/random pass.py b/Applications/Random Password Generator/random pass.py index 2b1e0be..3bb79a6 100644 --- a/Applications/Random Password Generator/random pass.py +++ b/Applications/Random Password Generator/random pass.py @@ -1,5 +1,5 @@ from tkinter import * -import random +from random import sample import string root = Tk() @@ -11,10 +11,7 @@ # function to generate the password def get_pass(): pass1 = string.ascii_letters + string.digits + string.punctuation - password = "" - - for x in range(pwd_len.get()): #loop to generate the user given length for password - password = password + random.choice(pass1) + password = "".join(sample(pass1, pwd_len.get())) passstr.set(password) #tkinter command to generate the gui @@ -24,4 +21,4 @@ def get_pass(): Button(root, text="Generate Password", command=generate).pack(pady=15) Entry(root, textvariable=passstr).pack(pady=2) -root.mainloop() \ No newline at end of file +root.mainloop()