</CODE></PRE></BLOCKQUOTE><P>I have a dictionary whose keys also appear are attribute values in a fc_1.</P><P>In the code below, I use the dictionary values to select by attribute rows (gid) in fc_1 with intention of writing the dictionary keys into another field in <SPAN>fc_1</SPAN> using arcpy.SelectLayerByAttribute_management.</P><P></P><P>This only writes the last key in the dictionary against all the selected values.</P><P></P><BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"><BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"><PRE class="lia-code-sample line-numbers language-none"><CODE>import arcpy
arcpy.env.workspace = r'home\delete\cccgdb.gdb'
gc = 'fc_1'
field ='FIDF'
dictio={"a": "AAA", "b": "BBB", "c": "CCC", "d": "DDD"}
fc_1_lyr = arcpy.MakeFeatureLayer_management(gc, "fc_1_lyr")
for i in dictio.keys():
for j in dictio.values():
#print (j)
whereClause = "gid = '%s'"%j
print (whereClause)
act = arcpy.SelectLayerByAttribute_management(fc_1_lyr, 'NEW_SELECTION', whereClause)
expression ='%s'%i
print(expression)
arcpy.CalculateField_management(act, field, expression)
arcpy.SelectLayerByAttribute_management(fc_1_lyr, "CLEAR_SELECTION")
print ('memaliza')<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
What am I doing wrong?