That's strange, I just tested the code again, and it worked for me.
One thing we can do is try it in piecemeal:
Here is a sample that just scrapes the total ESG score for Microsoft:
from bs4 import BeautifulSoup
import pandas as pd
import requests
import ipywidgets as widgets
from ipywidgets import interact
web_data = requests.get('https://finance.yahoo.com/quote/MSFT/sustainability?p=MSFT').text
soup = BeautifulSoup(web_data, 'html.parser')
esg_score = soup.find('div', {'class':'Fz(36px) Fw(600) D(ib) Mend(5px)'})
print(esg_score.text)
Try testing that out. It should output an ESG score of 16.