2

I trying to return three field values in same If Statment and conecate them, but i Get NULL value insted of the conecated fields

 getClass (!InDiameter! , !OutDiameter! , !TheridDiameter!, !FREQUENCY! )
     if FREQUENCY== 1:
        return In
     if FREQUENCY== 2:
        return(In &"-"& Out)

     if FREQUENCY == 3:
        return(In &"-"& Out &"-"&Therid)

enter image description here

1 Answer 1

5
getClass (In , Out , Therid, freq )
     if FREQUENCY== 1:
        return str(In)
     elif FREQUENCY== 2:
        return (str(In) + "-" + str(Out) )
     elif FREQUENCY == 3:
        return (str(In) +"-" + str(Out) + "-" + str(Therid) )
     else:
        return "other frequency" 

here is a quick fix. Concantenation in Python uses "+", and I converted your fields to string str() just to make sure they are not numeric (otherwise not necessary)

3
  • In the input parameters, you need to define frequency the same as in the rest of the code; FREQUENCY (or change in the code to freq).
    – Martin
    Mar 20, 2014 at 9:24
  • it's work but i get zero's (3.0 insted of 3) because i put str for double value Mar 20, 2014 at 9:48
  • 1
    you can use str(int(In)) in place of str(In)
    – radouxju
    Mar 20, 2014 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.