TypeError: 'in ' requires string as left operand, not NoneTypeįull error for the if statement: print(parser(lista_aziende_raw))įile "/home/enrico/Documents/Learning_Python/edo/web_scraper. You want to filter the list of lists so that only those inner lists remain that satisfy a certain condition. The expression references each element of. The full error for the list comprehension: File "/home/enrico/Documents/Learning_Python/edo/web_scraper.py", line 41, in Problem: Say, you’ve got a list of lists. An expression that resolves to a boolean value used to determine if an element should be included in the output array. lista_aziende_raw = ĮDIT: Here the output of print(lista_aziende_raw). I also tried to put it in an if statement, following this answer but that spits out TypeError: argument of type 'NoneType' is not iterable'. Answer by Penny Crane Python Filter List Range,Python Filter List with Another List,Python Filter List None,Short answer: To filter a list of lists for a condition on the inner lists, use the list comprehension statement x for x in list if condition(x) and replace condition(x) with your filtering condition that returns True to include inner list x, and False otherwise. Lista_aziende_raw.append(link.get('href')) Then the for loop goes to the second item in the list, which is not 2, but 3 Then that's removed from the list, and then the for loop goes on to the third item in the list, which is now 5. That means that the first time through the loop, i 1, so 1 is removed from the list. Is there a way to get what I want using list comprehension, or should I just use the re module? lista_aziende_raw = You're modifying the list while you iterate over it. I guess that in only looks for identical results, hence no results. I know for a fact that names that contain Azienda are present in the list, but I get an empty list. I'm a beginner, I want to filter the list lista_aziende_raw.
0 Comments
Leave a Reply. |