This simple problem teaches patterns you'll use often: 1. The accumulator pattern works for any aggregation. Sum, product, count, max, min all follow this structure.
2. Use _ for unused loop variables. It signals to readers that the index isn't needed.
3. Initialize before the loop. If total = 0 were inside the loop, it would reset every iteration.
4. += is cleaner than total = total + num. Use compound assignment for accumulation. These patterns will become second nature. Every time you need to combine multiple values into one result, reach for the accumulator pattern.