Find Index

Find the index of the first element matching a condition.

Code

General
next((i for i, item in enumerate(arr) if item['id'] == targetId), -1)

Parameters

Array

ID to find

Server

More Python Snippets