Using loop to go through range to select a single value each time


#1

I am trying to create a for loop or list comprehension that can go through a range, extract a single value each time by moving through each index in order, store it and then compare it to another value. for example:

def home():
for i in range (1,10):
###not sure how to extract one by one
### take that single value that was extracted from the range above and 
reduce  it from a index of type int
t_1 = (board[0] - i )   
### call upon a function and plug in result:
reducer(t_1)
if reducer is True:
 print ('hello world')
if reducer is False:
 home()

so basically the function home() runs in loops until it finds the correct number in the range, plugs it in as a parameter to the function reducer(t_1) and returns the result. The issue is I cannot understand how to create that first for loop or list comprehension to extract that single value one at a time from the required range, store it and then valuate it.

Thanks for the help


#2

Here we must assume that board[0] represents a numeric value (possibly an int, since range() only returns integers). We must also assume that the row is 9 elements in length to match your range parameters.

range is sequential and ordered meaning it has a direction and a common difference between terms. range(1, 10) generates an iterator over 1..9, in ascending order, with common difference of 1.

Still a little confused about what it is you are working with in the board list or what you are trying to do.