Seems like you want to extract a county name from a field and assign another field a county number based on the name, you could try something like:
counties = { 'ALACHUA' : 1,
'BAKER' : 2,
'BAY' : 3,
'BRADFORD' : 4,
'BREVARD' : 5,
'BROWARD' : 6,
'CALHOUN' : 7,
'CHARLOTTE' : 8,
'CITRUS' : 9,
'CLAY' : 10,
'COLLIER' : 11,
'COLUMBIA' : 12,
'DESOTO' : 13,
'DIXIE' : 14,
'DUVAL' : 15
}
countyKey = list(counties.keys())
cursor = [
[0, 'baker_2019pin_Dissolve'],
[0, 'calhoun_2019pin_Dissolve'],
[0, 'citrus_2019pin_Dissolve'],
[0, 'duval_2019pin_Dissolve'],
[0, 'alachua_2019pin_Dissolve'],
[0, 'clay_2019pin_Dissolve']
]
for row in cursor:
if row[1][:-17].upper() in countyKey:
row[0] = counties[row[1][:-17].upper()]
print row[0], row[1]
2 baker_2019pin_Dissolve
7 calhoun_2019pin_Dissolve
9 citrus_2019pin_Dissolve
15 duval_2019pin_Dissolve
1 alachua_2019pin_Dissolve
10 clay_2019pin_Dissolve
This uses a dictionary of county names, uses upper() to compare for a match and then uses the dictionary value for the county number. This process is easier to code than a long if/else.
Note that you will need to have dictionary entries that will match your county names if they include spaces, underscores, etc. (St. Lucie, Miami-Dade). It also assumes the the slicing [:-17] is correct.
Hope this helps.