ANN: Dogelog Runtime, Prolog to the Moon (2021)

alister alister.ware at ntlworld.com
Wed Sep 15 15:15:50 EDT 2021


On Wed, 15 Sep 2021 11:48:18 -0700, Mostowski Collapse wrote:

> And how do you iterate over the first n-1 elements of a list with n
> elements? This is what my code does:
> 
> i = 0 while i < len(term.args) - 1:
> ____mark_term(term.args[i])
> ____i += 1 term = term.args[i]
> 
> You can try yourself:

use a slice
as a generic example you can try in the interactive interpreter (aka 
REPL):

>>>items = [1,2,3,4,5,6,7,8,9,0]
>>>for item in items[:-1]:
>>>    print(item)

1
2
3
4
5
6
7
8
9

I should state for the record that I am no Python expert, I mainly visit 
this news group to learn.
sometimes from reading solutions & somtimes by trying to work out what 
the solution might be.

most productively by working out a solution & seeing if other posters 
agree (& working out why they don't)



-- 
The universe seems neither benign nor hostile, merely indifferent.
		-- Sagan


More information about the Python-list mailing list