I'll begin by stating I am very new to the python world!

My problem is this....

I am trying to use field calculator in ArcGIS Pro to return a calculation of values in other fields based on an if statement, if that makes sense! Not sure if it can be done?

The Calculation is

Qrp=Sum(Qs*Ls)/SumLs

Basically thus;

weightAADT(!rp!,!Qs!,!Ls!)

Code Block

def weightAADT(rp, Qs, Ls):

if rp=="Urban Two Lane":

return sum(Qs * Ls) / sum(Ls)

my error is "TypeError: 'float' object is not iterable"

Any help appreciated

I would assume that the problem is you're giving the sum built-in function a single number when it expects a collection of numbers.

2. Built-in Functions — Python 3.7.0 documentation

`sum`

(iterable[,start])https://docs.python.org/3/library/functions.html#sumSums

startand the items of aniterablefrom left to right and returns the total.startdefaults to`0`

. Theiterable’s items are normally numbers, and the start value is not allowed to be a string.Are your values Qs and Ls single float values or are they a collection of numbers?