William Shakespeare wrote a number of sonnets. This file from Project Gutenberg contains all of them, along with some other content. Your task is to write a Python3 program to count the number of sonnetes contained in the file. Hint: you’ll note that although the document is mostly unstructured, there are patterns to its formatting that can be used to identify when a sonnet starts and stops.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
URL = "http://www.gutenberg.org/files/1041/1041-h/1041-h.htm"
print("Searching " + URL + " for sonnets ...")
Open URL and get text
with urllib.request.urlopen(URL) as response:
text = response.read().decode("utf-8")
Clean up formatting of text
text = text.replace(" "...