chris.blinn799

Python If statement for Code Block

Discussion created by chris.blinn799 on Jun 16, 2011
Latest reply on Jul 25, 2011 by chris.blinn799
Hello,

I am new to Python, and programming all together really.  I am building a model where I want the user to select from a drop down list a value for a parameter (Climate Variable).  I then want to use the Calculate Value tool to then get a string value for a variable that will be used to choose a field from a feature attribute table (PYCLIM).  I wrote this If Statement (which I believe is wrong) to do such and I am getting the 000989 syntax error on Line 1.

def getCLIMVAR(PYCLIM):
 climvar = str(%Climate Variable%):
  if climvar == "Current Temperature":
   PYCLIM = "CUR_TEMP"
   return PYCLIM
  elif climvar == "High Temperature":
   PYCLIM == "HI_TEMP"
   return PYCLIM
  elif climvar == "Low Temperature":
   PYCLIM == "LOW_TEMP"
   return PYCLIM
  elif climvar == "Wind Chill Temperature":
   PYCLIM == "CHILL_TEMP"
   return PYCLIM
  elif climvar == "Dew Point Temperature":
   PYCLIM == "DEW_TEMP"
   return PYCLIM
  elif climvar == "High Temperature":
   PYCLIM == "HI_TEMP"
   return PYCLIM
  elif climvar == "Relative Humidty":
   PYCLIM == "REL_HUMID"
   return PYCLIM
  elif climvar == "Solar Radiation":
   PYCLIM == "SOL_RAD"
   return PYCLIM
  elif climvar == "Wind Speed":
   PYCLIM == "WIND_SPEED"
   return PYCLIM
  else climvar == "Highest Wind Gust":
   PYCLIM == "HI_WIND_GUS"
   return PYCLIM


Any help would be appreciated.  Thank you in advance! If the code is horrible, please understand that I wrote this without ANY python experience.

Outcomes