Debug School

rakesh kumar
rakesh kumar

Posted on • Updated on

How to select specific element of list using slicing in python for webscraping

My Code

match_point = soup.find_all('td', class_="table-body__cell u-center-text")
match_point
Enter fullscreen mode Exit fullscreen mode

output

Image description

Get all element of 1s,3rd and 5th so on odd position

match_data = match_point[::2]
match_data
Enter fullscreen mode Exit fullscreen mode

Output

Image description

Get all element of 1s,3rd and 5th so on even position

point_data = match_point[1::2]
point_data
Enter fullscreen mode Exit fullscreen mode

Output

Image description

list slicing

Top comments (0)