AnsweredAssumed Answered

Empty String on Field Calculator

Question asked by ionarawilson on Oct 25, 2012
Latest reply on Oct 26, 2012 by ionarawilson
I am taking a web course called "Use Python in ArcGIS Desktop 10" and one of the exercises is to write a python script on the field calcualtor to change the types of schools:

def label(name, type):
if type == "HIGH":
  return name + " HS"
if type == "MIDDLE":
  return name + " MS"
elif type == "ELEMENTARY":
  return name + " ELEM"

But the type column has one record with an empty string and I get an error because of that. I know I could use an "else" statement  to take care of that but I have had this issue before and would like to know how I can include that in the python script. I tried:

if  type == " ":
  return  name + " "

I also tried

if type is None:
return  name + " "

I also tried
if len(type) == 0:
return  name + " "

And a couple more statements, but nothing works. Do you guys know what I can use to account for the empty string? Thanks!!!