Using python Write a program that: Opens a file named”Chap7pt1P1.txt” Asks the user to enter a string of charactersStores the string of characters in the above file Closes the fileOpens the file again to read from it Reads the string of charactersin the file Prints the string on the screen Closes the file Sampleexecution: Enter a string of characters: Today is a great day! Thefile contains the text Today is a great day!
This is what I have and its not working
def main():
inputFile = open(“Chap7pt1P1.txt”,”w”)
line = inputFile.readline()
while line !=””:
outfile.write(“Enter a string of characters:”,line)
line = infile.readline()
outfile.write(“The file contains the text”,line)
inputFile.close()
main()
Solution
def
OR
OR