Following snippet
resp.raise_for_status()
soup = BeautifulSoup(resp.text, 'html.parser')
titles = [tr.find("a").text for tr in soup.find(class_="article-table").find_all("tr")[1:]]
``` causes ```
AttributeError Traceback (most recent call last)
Cell In[14], line 8
6 resp.raise_for_status()
7 soup = BeautifulSoup(resp.text, 'html.parser')
----> 8 titles = [getattr(tr.find("a"), 'text') for tr in soup.find(class_="article-table").find_all("tr")[1:]]
9 titles
AttributeError: 'NoneType' object has no attribute 'text'
``` I assume that this is because type of tr.find() is not known at the time of evaluation. However, why would python of all language care about it? I mean, it diesnt need to know type to call .find method, and if tr would not have it then it will throw an error. Why is that different?