Skip to content

Commit 450170d

Browse files
committed
Merge pull request geekcomputers#9 from bevennyamande/patch-2
Update testlines.py
2 parents 95175a9 + 97685bf commit 450170d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

testlines.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
# Last Modified :
55
# Version : 1.0
66

7-
# Modifications :
7+
# Modifications : beven nyamande
88

9-
# Description : This very simple script open a file and prints out 100 lines of whatever is set for the line variable
9+
# Description : This very simple script open a file and prints out 100 lines of whatever is set for the line variableest you want to print\n" # This sets the variable for the text that you want to print
1010

11-
line="Test you want to print\n" # This sets the variable for the text that you want to print
12-
f=open('mylines.txt','w') # Create the file to store the output
13-
for i in range(1,101): # Loop 100 times
14-
f.write(line) # Write the text to the file
15-
f.close() # Close the file
11+
12+
def write_to_file(filename,txt):
13+
with open(filename,'w') as file_object:
14+
s = file_object.write(txt)
15+
16+
17+
if __name__ == '__main__':
18+
write_to_file('test.txt', 'i am beven')
1619

0 commit comments

Comments
 (0)