Using Python Write Program Opens File Named Chap7pt1p1txt Asks User Enter String Character Q37118642

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

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.