Formulas such as and have brackets. You will make the program count atoms through a bracket, check whether an equation is balanced, and find the one equation in a list that is not.
The idea. The number after a bracket multiplies every atom inside the bracket. The number in front of a formula multiplies the whole formula.
Your tasks.
count_atoms, add n times the number after the bracket for each atom inside it.balanced, return True when both sides have the same counts.wrong, the name of the equation in equations 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…
With Standard, you also open 6 more problems, 1 Python lab and 1 extra course. Everything you have used here stays free, always.