Whenever a defendant is convicted of a crime or attempt to commit a crime which is distinguished into degrees, the jury, or the court if a jury trial is waived, must find the degree of the crime or attempted crime of which he is guilty. Upon the failure of the jury or the court to so determine, the degree of the crime or attempted crime of which the defendant is guilty, shall be deemed to be of the lesser degree.