I want calculate the number of time a 0 appears in a "list of lists" web scraped, it's like my list of lists is not a list because when I print, it's done that :
[3]
[1]
[3]
[3]
[1]
[1]
[0]
[0]
[1]
[1]
if it's really is a list of list it's should tell me this :
[[3],[1],[3],[3],[1],[1],[0],[0],[1],[1]]
So, list or not list I cant count the number of time the 0 is here, how can I do for count the 0 ?
In this exemple, there is two 0, so the result is = 2
There is my code, maybe you can tell me how I can, I tried count(0) and other method, but it's dont work
from bs4 import BeautifulSoup
import requests
from csv import writer
url= "https://blablablabla.htm"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
lists = soup.find_all('tr', class_="mat1")
with open('file.csv', 'w', encoding='utf8', newline='') as f:
thewriter = writer(f)
for list in lists:
but = list.find('td', class_="tj1").text.replace('\xa0', '').replace(" ", "1")
info = but[3:]
infos = len(info)
infoss = int(infos)
print(infoss)
print(infoss) is :
3
1
3
3
1
1
0
0
1
1
and i need a code which tell me the number of 0 in this list, so here it's 2