Access last element after iteration
On 2020-07-07, Frank Millman <frank at chagford.com> wrote:
> After iterating over a sequence, the final element is still accessible.
> In this case, the variable 'i' still references the integer 4.
> Is this guaranteed in Python, or should it not be relied on?
It is guaranteed, *except* if the sequence is empty and therefore the
loop never executes at all, the variable will not have been assigned
to and therefore may not exist.