Nov-05-2021, 07:52 PM
What is Isin? ISIN as is in International Securities Identification Number or "Is this in that?"
You want to parse an address to find the city, find a driver for that city, and then append the driver's name to the address? Is that what you want to do?
An easy way is to search for all the keys in your driver database.
Both of these fail if you have the same city name used for different cities like Portland Maine and Portland Oregon.
You want to parse an address to find the city, find a driver for that city, and then append the driver's name to the address? Is that what you want to do?
An easy way is to search for all the keys in your driver database.
drivers = { "John":"New York", "Tim":"Los Angeles" } addresses = [ "47 W 13th St, New York, NY 10011, USA", "1419 Westwood Blvd, Los Angeles | CA 90024-491", "1222 S 27th St, Lincoln, NE 68502, USA" ] for address in addresses: for driver, city in drivers.items(): if city in address: print(f"{address} {driver}") break else: print(f"{address} No Driver Available")
Output:47 W 13th St, New York, NY 10011, USA John
1419 Westwood Blvd, Los Angeles | CA 90024-491 Tim
1222 S 27th St, Lincoln, NE 68502, USA No Driver Available
This becomes inefficient if you have lots of addresses and lots of drivers. If that is the case you should parse the address to extract the city and have a dictionary of cities (keys) and drivers (values).Both of these fail if you have the same city name used for different cities like Portland Maine and Portland Oregon.