Chocolate scraping

I’m at step 14 and keep getting this error. I typed in the exact code from the hints. I’m not sure why my code is not working. I’d really appreciate your feedback.

Also, how can I see the scatterplot on the local page?

cocoa_percents = []
cocoa_percent_tags = soup.select(".CocoaPercent")

for td in cocoa_percent_tags[1:]:
  percent = int(td.get_text().strip('%'))
  cocoa_percents.append(percent)
Traceback (most recent call last):
  File "script.py", line 37, in <module>
    percent = int(td.get_text().strip('%'))
ValueError: invalid literal for int() with base 10: '73.5'

Your error message is telling you that there’s an issue relating to int() and 73.5.

Make this a float instead and it should work.

It works. Thank you! How can I find the scatterplot on the local page? I just can’t find it anywhere!

Hi @evelyn_l,

Link to project: Chocolate Scraping with Beautiful Soup

What code did you use to create and show the plot? Did you look for the plot by typing localhost in the address bar of this panel?:

1 Like