You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support optional start index with FOR ... IN ENUMERATE loops #3781
The FOR ... IN ENUMERATE loop allows looping over a list of items so that you automatically get the index of the item as well:
FOR ${index} ${item} IN ENUMERATE @{items}
Log Item at index ${index} is '${item}'.
END
Indices start from zero, but sometimes other indexing is needed. It's possible to increment the index in the loop but that requires either using Evaluate (an extra step) or inline Python evaluation (complicated):
FOR ${index} ${item} IN ENUMERATE @{items}
${index} = Evaluate ${index} + 1
Log Item ${index} is '${item}'.
END
FOR ${index} ${item} IN ENUMERATE @{items}
Log Item ${{$index + 1}} is '${item}'.
END
The FOR ... IN ENUMERATE loop is inspired by Python's for index, item in enumerate(items) syntax and with it you can use a custom index like enumerate(items, start=1). The same approach works also well in our case:
FOR ${index} ${item} IN ENUMERATE @{items} start=1
Log Item ${index} is '${item}'.
END
Activity
Support optional start index with `FOR ... IN ENUMERATE` loops.