I have tried examples from the GIS support website and many more, but I cannot figure out how to get a codeblock for a field calculation to work within ArcPy.
Part of my code is underneath, it is a continuation of a table being added (multiple calculate fields). However the earlier calculations do not use a codeblock, the last one does. As a side note to the codeblock section, wing.IDE will not let me indent the code further than this. I hope that that is not where it goes wrong
Codeblock_for_geometry_10 = """ def val: if [AFSPRAAK] = 'Huur' then val = 'D102' elseif [AFPSRAAK] <> 'Huur' then val = 'D101' end if """
Field calculation (RVB_geometry_9 being the previous calculation on the table):
RVB_geometry_10 = arcpy.CalculateField_management(RVB_geometry_9, "NIVEAU_3", "val", "VB", Codeblock_for_geometry_10)
The error I get: A field name was not found or there were unbalanced quotation marks.
As far as I can tell the quatation marks are correct and the fieldnames are aswel. I would like to learn what I am doing wrong here for future calculations.