for each index

 List Manipulations - for each index

The For each index Deluge List syntax executes a set of tasks repeatedly, for each element in the list and provides index starting from 0 as instance variable.


for each index <variable> in <list>


<variable> is instance variable name which iterates each index starting from 0.
<list> the list name


In the following sample code, val is the user-defined instance variable name which will hold the value of the index, starting from 0, in the sports_list. If "Football" is found in the list, the user will be alerted with - "Football is available".

for each index val in sports_list
sports = sports_list.get(val);
if(sports == “Football”)
alert “Football is available”;