I have a dataframe containing city names in which I converted to a list. I need to take each indivudal city name and apply search it up using the search_by_city option in US zipcodes to find the corresponding zip. Below is my code
from uszipcode import SearchEngine
search =SearchEngine()
cities= list(data['Nearest City '])
print(cities)
Output:
['Dallas', 'Falls Church', 'Anniston', 'New Brockton']
For example cities[0], gives me the name 'Dallas", and if I apply the following code I get the zipcode of such city.
zipy= search.by_city(cities[0])
How do I iterate through the entire list "cities" to get the zip code for each of the city element names within the list?
I know itll be a for loop of some kind but having issue
question from:
https://stackoverflow.com/questions/65832760/iterate-through-element-in-list 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…