'How can I add new features to Python Password Generator?

I'm working on a Python password generator code and I want to create an option to ask the user if they want to determine which punctuation characters might be in the generator and to store it in a file. Here is the code below: #importing Libraries

from tkinter import *
import random, string
import pyperclip




###initialize window

root =Tk()
root.geometry("500x300")
root.resizable(0,0)
root.title("DataFlair - PASSWORD GENERATOR")

#heading
heading = Label(root, text = 'Random Password Generator' , font ='arial 15 bold').pack()
Label(root, text ='DataFlair', font ='arial 15 bold').pack(side = BOTTOM)


###select password length
pass_label = Label(root, text = 'PASSWORD LENGTH', font = 'arial 10 bold').pack()
pass_len = IntVar()
length = Spinbox(root, from_ = 8, to_ = 32 , textvariable = pass_len , width = 15).pack()


#####define function

pass_str = StringVar()

def Generator():
    password = ''
for x in range (0,4):
        password = random.choice(string.ascii_uppercase)+random.choice(string.ascii_lowercase)+random.choice(string.digits)+random.choice(string.punctuation)
for y in range(pass_len.get()- 4):
        password = password+random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation)
        pass_str.set(password)


###button

Button(root, text = "GENERATE PASSWORD" , command = Generator ).pack(pady= 5)

Entry(root , textvariable = pass_str).pack()

########function to copy

def Copy_password():
    pyperclip.copy(pass_str.get())

Button(root, text = 'COPY TO CLIPBOARD', command = Copy_password).pack(pady=5)

# loop to run program
root.mainloop()


Solution 1:[1]

you can save passwords to a file, and You can get a word from the user and create a password, I have an old file in my github account but simple. passwordgenerator

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yasincan Olcay