Objective
Create a Python program that uses traces (print messages) to follow the value of the variables step by step, the simplest debugging technique.
Instructions
- Read a positive integer
nand go through its digits from left to right (withstr(n)) adding them up in the variabletotal. - In each turn show a trace with the format
Digit D: total = S, whereSis the already updated total. - When finished show
Total sum: S.
1234
Digit 1: total = 1
Digit 2: total = 3
Digit 3: total = 6
Digit 4: total = 10
Total sum: 10
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise