def to_int(val, default=0):
 try:
  val = int(val)
 except:
  val = default
 return val

def to_int ( val , default = 0 ) : try : val = int ( val ) except : val = default return val
convert everything but none to an int .