- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilewrite.py
More file actions
Latest commit
14 lines (10 loc) · 571 Bytes
/
Copy pathFilewrite.py
File metadata and controls
14 lines (10 loc) · 571 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
defmain(): #defining the main function
out=open("test.txt","a")#opening the fileif file is not created then it will create the file
out.write("\nCool!")#appending the file means adding the text to the file
out.close() #closing the file
f=open("test.txt", "a")
foriinrange(5):
inputtofile=input("Enter the string to the file:")#taking input form the use rto add in the file
f.write("\n{}".format(inputtofile))#assigining the variable the file write
f.close()#closing the file
if__name__=='__main__':main()