a simple character recognition code in python