Re: Access last element after iteration

2020-07-07 Thread dn via Python-list
On 8/07/20 12:45 AM, Chris Angelico wrote: On Tue, Jul 7, 2020 at 10:28 PM Frank Millman wrote: Hi all After iterating over a sequence, the final element is still accessible. In this case, the variable 'i' still references the integer 4. Yes, it's guaranteed. It isn't often useful; but the

Re: Access last element after iteration

2020-07-07 Thread Chris Angelico
On Tue, Jul 7, 2020 at 10:28 PM Frank Millman wrote: > > Hi all > > After iterating over a sequence, the final element is still accessible. > In this case, the variable 'i' still references the integer 4. > Yes, it's guaranteed. It isn't often useful; but the variant where there's a "break" in th

Re: Access last element after iteration

2020-07-07 Thread Jon Ribbens via Python-list
On 2020-07-07, Frank Millman 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 an

Access last element after iteration

2020-07-07 Thread Frank Millman
Hi all After iterating over a sequence, the final element is still accessible. In this case, the variable 'i' still references the integer 4. Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for mo