The Python Calculator

Step 8 – Fix the problem

Code helper image

The problem happens when you try and divide by 0.

This can't be done. You know that from maths.

It causes the program to crash. We don't want that to happen.

There's a way we can fix this...

  1. You need to add another if statement inside the section of the program that deals with division
  2. This checks whether number2 is zero. If it is it displays a message
  3. Otherwise you can divide, so the program does that
  4. This is a bit tricky. Check your indents are right
  5. Run your program and test division – both division that should work and division by 0

This should just about work now.