Attempting to use an update cursor to update a field 'Cost' by multiplying the value in the field 'Area' by a value input by the user. The trouble seems to be getting the variables "Price1" and "Price2" to work inside the cursor's If statements. If I simply replace the variable with a number, such as 2, then the script works fine, but it really needs to multiply a variable that the user has entered. The variable that the user enters will be a money value, so it's of type Double with 2 decimal places. The error I get is "can't multiply sequence by non-int of type 'float'". Here's a snippet of the code:
Code:
Price1 = arcpy.GetParameterAsText(0)
Price2 = arcpy.GetParameterAsText(1)
fcName = "My_lyr"
fields = ['Area','Description','Cost'] #Note that 'Area' is type DOUBLE, 'Description' is TEXT, and 'Cost' is DOUBLE
CostCursor = arcpy.da.UpdateCursor(fcName,fields)
for row in CostCursor:
if row[1] == "Category 1":
row[2] = (row[0] * Price1)
elif row[1] == "Category 2":
row[2] = (row[0] * Price2)
else:
row [2] = 0
CostCursor.updateRow(row)
del row
del CostCursor