Problem Description
Write a python program to create a file and display the contents
Hint:
1. Create a File
2. Take four inputs from the user and add the four lines to the file
3. Display the contents of the file written in the output
Input:
1. Filename
2,3,4,5 = File contentsCODING ARENA
x=input()
f = open(x,"w")
for i in range(4):
a=input()
f.write(a)
f.close()
f = open(x,"r")
for line in f:
print(line)
f.close()
Test Case 1
Input (stdin)sample.txt This is First Line This is Second Line This is Third Line This is Fourth Line
Expected OutputThis is First LineThis is Second LineThis is Third LineThis is Fourth Line
Test Case 2
Input (stdin)sample.txt eLab Tool is an auto evaluation tool
Expected OutputeLab Tool is an auto evaluation tool
No comments:
Post a Comment