How to fix error: list index out of range?

Question:

I cant solve this problem. I really need help

here is my code:
https://dpaste.org/PqpYE#L33

here is the error that I am having:

File "test.py", line 30, in <module>
percent = soup.find('tbody').find_all('tr')[a].find('td').find_all(class_ ='styled__PercentContainer-sc-1qtnlbe-0 eeuaGk')
IndexError: list index out of range
Asked By: JustName

||

Answers:

Shift a+=1 to end of loop. Python indexing start with 0.

Answered By: Chris Seeling

You can iterate through the row and index in tandem by doing for a, i in enumerate(row): then you don’t need to count up the index manually (you can remove the a+=1 and the initialization a=0).

Answered By: MangoNrFive