I'm parsing a JSON file into a list and then from that list am looking for certain values. For instance - I'm searching each item in the list for the occurrence of the word "Audi".
The code works for some occurrences but not all...
Here is a partial snipping of the list printed out -
for i in data['custom_audiences_v2']:
advertisers.append(i)
adCount += 1
print(i)
Output:
Atlanta Autos
Atlanta OsteoArthritis Clinic LLC
Atlanta Toyota
Atlantic Broadband
Audi Nashua
Audi Bellingham
Audi Clearwater
Audi Columbia
Audi Dominion
Audi Fort Myers
Audi Jacksonville
Audi Lakeland
Audi Melbourne
Audi Mission Viejo
Audi Naples
Audi North Austin
Audi North Orlando
Audi Orange Park
Audi Richmond
Audi Service Conshohocken
Audi Stuart
August Hall
Aurelie.erikson
AUSTEDO® (deutetrabenazine) tablets
Here is the code I'm using to parse out and remove from the original list:
for i in advertisers:
if i.lower().count('audi') > 0:
carAds.append(i)
advertisers.remove(i)
Here is the list after I've attempted to remove anything with "audi" in it:
Atlanta Toyota
Atlantic Broadband
Audi Bellingham
Audi Columbia
Audi Fort Myers
Audi Lakeland
Audi Mission Viejo
Audi North Austin
Audi Orange Park
Audi Service Conshohocken
August Hall
Aurelie.erikson
And this is what my carAds list looks like after it's parsed through the original list. You'll notice that it's picked up all sorts of various audi items from the original list...
for i in carAds:
print(i)
Audi Nashua
Audi Clearwater
Audi Dominion
Audi Jacksonville
Audi Melbourne
Audi Naples
Audi North Orlando
Audi Richmond
Audi Stuart
Bommarito Audi West County
DCH Millburn Audi
Envision Audi of West Covina
Fillmore Auditorium
Fiore Audi
Jack Ingram Audi
Molle Audi of Kansas City
The Bell Auditorium
Tivoli Theatre ⢠Walker Theatre ⢠Memorial
Auditorium
find is working in the same manner. Any assistance is greatly appreciated. Thanks!