1

I am using the following pre-logic Python code to try to catch Null, empty, or "0" string values in the "street" column and then return a "V" value if it is one of those. While the code runs and works on some rows, it doesn't seem to be catching all empty cells. Am I missing a case? Or could it be that there are multiple spaces, and if so, how can I check for those?

Pre-Logic:

def check(Street):
  if Street is None or Street == "" or Street == "0" or Street == None or not Street or Street == " ":
    return "V" 
  else:
    return " "

Verfied =

check(!Street1!)

1 Answer 1

2

The strip method on a string will remove spaces and linebreaks so you can use it in your case to check for cases of multiple spaces.

def check(Street):
  if Street is None or Street.strip() == "" or Street == "0":
    return "V" 
  else:
    return " "
0

Your Answer

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

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