I have two files:
text
and
program.py
I insert text into my
text
file using the line:
inp=input('Text by the user')
with open("text.py", "a") as myfile:
myfile.write(inp)
How can i make the program delete the line in text having it say:
text2
not
text1 text2
when run two times?
Open in write mode (w) instead of append mode (a). This blanks the file before writing to it.
inp=input('Text by the user')
with open("text.py", "w") as myfile:
myfile.write(inp)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With