initialisation

Giving a variable its first value before it is used, especially before a loop that updates it.

In more detail

Forgetting it gives NameError on the first update; putting it inside the loop resets it every pass, a classic bug. Choose the initial value that makes the first update right, such as 0 for a sum.

Related terms

Taught in

References