Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need Help Debugging Python Code with errors listed below. How many words are in

ID: 3908700 • Letter: N

Question

Need Help Debugging Python Code with errors listed below.

How many words are in the text of William Henry Harrison's 1841 inaugaral address? The address can be found at https://www.webucator.com/how-to/william-henry-harrisons-inaugural-address.cfm. Its contents are in a div tag with the id 'content-main'. : from bs4 import BeautifulSoup import re f = open ('https://www.webucator .com/how-to/william-henry-harrisons-inaugural-address .cfm. ). read() soup Beautifulsoup(f) count soup.find ( 'div', attrs-'id': 'content-main') print (count) FileNotFoundError Traceback (most recent call last) ipython-input-32-d44285762593> in 3 -open ea count-soup.findAll( 'div',attrs-'id' 'content-main' FileNotFoundError: (Errno 2] No such file or directory: 'https://www.webucator.com/how-to/william-henry-harrisons-ina ugural-addres s . cfm .

Explanation / Answer

Q1

instead of open you should use urlopen and you will have to import urlib

Q2

You can't use split as it is a string function and not applicable on Counter object

You can use most_common method and then use the returned list of tuples to access the last elements which will give you the least common elements.

Q3

Same error is here.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote