This simple problem teaches patterns you'll use often: The accumulator pattern works for any aggregation. Sum, product, count, max, min all follow this structure.
Use _ for unused loop variables. It signals to readers that the index isn't needed.
Initialize before the loop. If total = 0 were inside the loop, it would reset every iteration.
+= 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.