0

I'm trying to figure out how to list user inputs without overwriting the previous text inputted, but instead adding more into it infinitely.

This is my code so far:

def main():

    domain=input('Enter domain: ')
    email=input('Enter your email or username: ')
    password=input('Enter your password: ')



    text_file = open("Data.txt", "w")

    text_file.write("Domain of login: "+domain+'\n'+"Email/username: 
    "+email+'\n'+"Password: "+password)
    text_file=open("Data.txt", "r")
    text = text_file.read()
    print(text)
    text_file.close()

main()

This is the output example:

Domain of login: Facebook.com
Email/username: 1234567@email.com
Password: pas5word

This is the concept I'm trying to aim for:

Domain of login: Facebook.com
Email/username: 1234567@email.com
Password: pas5word

Domain of login: Youtube.com
Email/username: 1234567@email.com
Password: pas5word2

Domain of login: Twitter.com
Email/username: 54321@email.com
Password: pas5word3
Andrej Kesely
  • 168,389
  • 15
  • 48
  • 91
  • I think what you are looking for is "appending to a file". Please see this https://stackoverflow.com/questions/4706499/how-do-you-append-to-a-file – gaganso Jul 11 '18 at 04:27
  • Are you trying to use a loop, or continue running the program manually to add to the file? – OneCricketeer Jul 11 '18 at 04:31

0 Answers0