The defendant may be found guilty of any lesser offense the commission of which is necessarily included in that with which he is charged; or of a lesser offense than that with which he is charged; or of an attempt to commit either the offense charged or any offense the commission of which is necessarily included therein, or of any degree thereof, if the attempt constitutes in itself, an offense.