Python: How to select all other elements in a for loop

advertisements

Let's say I have:

def recursive(data):
    for i in data:
        if condition:
            recursive(HERE IS THE ISSUE)

How do I pass in the data from the current i to the final element in the list?


Check out enumerate this will also return the current loop index which you can then slice with.

def recursive(data):
   for i,j in enumerate(data):
      if condition:
         recursive(data[i:])