This probably works, but seems wrong.  Surely the second "var" should be "var[0]", and perhaps you just want:   if var[0].isdigit():