I'm stuck on this homework assignment that I have.
Below are the instructions for it
I finished the first 2 steps in the assignment which is in the code below:
How would I open and create a new file and put the first paragraph of the MLK speech into it?
I believe we are supposed to use a while loop to do that
Thanks!
Below are the instructions for it
Quote:You are an English major who has been given assignment to analyze Dr. King's
"I Have A Dream" speech.
Open the file that contains Dr. King’s “I have a dream” speech.
Print the total number of characters in the speech.
Open another file for output.
Write only the first paragraph of this speech to that file.
I finished the first 2 steps in the assignment which is in the code below:
Code
# Open the file
inputFile = open("mlkspeech.txt", "r")
# Read the file
data = inputFile.read()
# Determine # of characters in file
numberOfCharacters = len(data)
print("Number of Characters in the file:", numberOfCharacters)
inputFile.close()How would I open and create a new file and put the first paragraph of the MLK speech into it?
I believe we are supposed to use a while loop to do that
Thanks!


