- #1
Adam Kohnle
- 21
- 5
Hello everyone, I am trying to create a sign out sheet as if I am a teacher and its so then people can sign out electronically. I know very little python and I have googled most things. I have never worked with a text file before. I am trying to make so it will ask my name, destination, and time and it will print it like this:
Adam Kohnle Bathroom 1:21and then after I close the python program, others can use the same python program and also sign out so it can look like this:
Adam Kohnle Bathroom 1:21
John Cena Nurse 1:33
but my problem is that everytime I relaunch the python program, it instead replaces the text previously typed into that text file. How do I make so it keeps the data the first student typed in and just adds the second students data? Here is my code so far:
Also I have no idea what the # file-output.py is. I know it is a comment but I just copied it off of online and I have been just heavily editing the initial code. Well heavily is relative, what I mean is it was originally this:
Adam Kohnle Bathroom 1:21and then after I close the python program, others can use the same python program and also sign out so it can look like this:
Adam Kohnle Bathroom 1:21
John Cena Nurse 1:33
but my problem is that everytime I relaunch the python program, it instead replaces the text previously typed into that text file. How do I make so it keeps the data the first student typed in and just adds the second students data? Here is my code so far:
Python:
# file-output.py
f = open('Sign Out Sheet.txt','w')
f.write(input('What is your full name?'))
f.write('')
destination = input('What is your destination?')
f.write(destination)
f.write('')
f.write(input('What is the time?'))
f.write('')
f.close()
Python:
# file-input.py
f = open('helloworld.txt','r')
message = f.read()
print(message)
f.close()
Last edited by a moderator: