Function that causes invalid values

Here is my function, an important line where I call f () again.

def f(num,xyz,possible,temp): y = num%9 x = num-y print num for xyz[num] in possible[num]: if ispossibility(temp,xyz[num],x,y) == True: temp[num] = xyz[num] if num != 80: f(num+1,xyz,possible,temp) # i call f() with num incremented else: print 'yes' exit() 

Program exit

 0 1 2 3 4 5 6 7 8 3 2 3 3 

The problem is that whenever the f () function is called, the num variable should always be incremented by 1. But from the result, f () is called with num as 3 when it was before eight. And so I wonder how this is possible (the output should be 9 battles, not 3), when f () is always called w / num, increasing by 1. I’ve been looking at this function for some time, and I really don’t understand that going on.

+2
source share
1 answer

You call f(num+1, ...) inside the loop, so you can call f() with the same value for num several times.

+4
source

Source: https://habr.com/ru/post/909031/


All Articles