So, I'm making a password generator and trying to save it to a text file. This is how it looks:
import string
from random import *
characters = string.ascii_letters + string.punctuation + string.digits
password = ("".join(choice(characters) for x in range(randint(8, 16))))
print(password)
choice = input("What is your password for?")
F = open("Passwords.py", "w")
F.write("\n" + choice + ": " + password)
F.close()
But for some reason, the text file only saves the most recent password. And for this to actually be applicable, I need the text file to save more than one password. Is there any way to prevent this?