When the penalty for an offense is prescribed by one law and altered by a subsequent law, the penalty of such second law shall not be inflicted for a breach of the law committed before the second took effect, but the offender shall be punished under the law in force when the offense was committed.