Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def file_append(username):
- """ This subprogram will append the username and password to the text file
- ‘logins.txt’
- """
- myFile = open('logins.txt','a')
- # The file is opened in append mode, meaning anything written in this
- # procedure will not overwrite current data stored on the file.
- password = "Password123\n"
- # the variable password is set to 'Password123' so that it can be added
- # to the record.
- record = "Username: " + username + " " + "Password: " + password
- # Combines username and password (along with a spacer) into one variable
- # so it can be appended to the file more easily
- myFile.write(record)
- # The variable 'record' is appended to the file
- myFile.close
- # File is closed so that other programs or the user can now open it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement