Index Out Of Range When Seems to Exist

Brand new programmer.

Trying to scrape a specific aspect with the class below. There are 5 in total in the inspect window. When I try to print the 3rd index, it gives me an ‘out of range’ error. Any clue as to why?

import bs4
from bs4 import BeautifulSoup
import requests
import lxml

vegas_insider = requests.get('https://www.vegasinsider.com/college-football/matchups/', 'r').text
soup = BeautifulSoup(vegas_insider, 'lxml')

closing_line = soup.find('td', class_ = 'viCellBg2 cellBorderL1 cellTextNorm padCenter').text[2]

print(float(closing_line))

Answer

find() returns only one element, the first one it finds. If you want all elements with a specific tag you have to use find_all() instead.

https://beautiful-soup-4.readthedocs.io/en/latest/index.html?highlight=find#find