...

/

Solution: Bugs and Exceptions in the Code

Solution: Bugs and Exceptions in the Code

Review the solution of fixing bugs and exceptions in the code.

We'll cover the following...

Task 1 solution

The bug in the Python code is in the last two print statements. The variable result is overwritten with the second function call add(12, 15), so the first calculation of 12 + 10 is lost. Therefore, the two print statements will output the same value, which is the result of the second function call.

To fix the bug, we can modify the code as follows:

Access this course and 1400+ top-rated courses and projects.