Q4:Delete all the reference numbers in the text (including their brackets). It should delete the following: [8] etc. Before deleting them, print the list of those reference numbers then print the following: There are {length of list} references numbers to be deleted. My codes are below:
import re
with open('macOS.txt', 'r') as f:
content = f.read()
temp = re.sub('<[^>]*>', '', content)
print(f'There are {len(temp)} references numbers to be deleted.')
print(temp)
While I am not sure is this right answer? For delete [8],[9] I used re.sub('<[^>]*>', '',content)
Q5:Using the new text from no.4, split the text to check how many sentences are in the text. Be careful to not split on the period in something like the following:
by Apple Inc.
since 2001 OS X 10.1 etc.
Then print the following: There are {length of list} sentences in the text.
But in Q5 I don't know how to use the new text from Q4? Anyone can please guide me how to do this?
[8]with'<[^>]*>, you could use\[\d+]to remove the square brackets that contain 1 or more digits.