ANN: Dogelog Runtime, Prolog to the Moon (2021)
DFS
nospam at dfs.com
Wed Sep 15 17:26:17 EDT 2021
On 9/15/2021 5:10 PM, Mostowski Collapse wrote:
> And how do you only iterate over n-1 elements?
> I don't need a loop over all elements.
>
> With array slicing?
>
> Someting like:
>
> for item in items[0:len(items)-2]:
> ___print(item)
>
> Or with negative slicing indexes? Problem
> is my length can be equal to one.
>
> And when I have length equal to one, the
> slice might not do the right thing?
>
> LoL
From the python command prompt:
items = [1,2,3,4]
for itm in items:
print(itm)
1
2
3
4
for itm in items[:-2]:
print(itm)
1
2
for itm in items[:-3]:
print(itm)
1
for itm in items[:-4]:
print(itm)
(no result, no error thrown)
for itm in items[:-5]:
print(itm)
(no result, no error thrown)
More information about the Python-list
mailing list