You will finish a program that names a straight-chain aldehyde or ketone from the number of carbon atoms and the place of the C=O. Three small parts are missing.
The idea. The C=O at an end of the chain makes an aldehyde, named -al. Inside the chain it makes a ketone, named -one. The number is counted from the end that gives the carbonyl carbon the smaller value.
Your tasks.
locant(n, place) so that it returns the smaller of place and n + 1 - place.is_aldehyde(n, place) so that it is true when the C=O is on the first or the last carbon.name_of, return the right ending for an aldehyde, for propanone or butanone, and for the other ketones.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…