Consider using recursion to "simulate" what a for-loop does. Each recursive call of some function named ForLoop will represent one iteration of the for-loop. Again, here is the for-loop to simulate:

1
2
3
4
print "Start" ,  
for i in range(4):
  print i ,
print "Done", i

The output from this example is: Start 0 1 2 3 Done 3. Here is an attempt at doing the same with recursion:


Recursive Simulation

def ForLoop(v):
  print v ,
  if v<=2:
    ForLoop(v+1)
print "Start" ,
ForLoop(0)
i = 3
print "Done", i