A reaction is written as a list of molecules, each with a number in front and its atoms. You will make the program count the atoms of each element on one side, say whether the two sides match, and find the one reaction in a list that is wrong.
The idea. Atoms are neither created nor destroyed in a reaction, so each element must have the same number of atoms on both sides.
Your tasks.
count, add number * n to totals[element] for every atom of every molecule.balanced, return True when the two sides have the same counts.wrong, the name of the reaction in reactions that is not balanced.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…