educative.io

Educative

Explanation on the solution

Can anyone explain me this line from the solution in the given link:

I can’t understand this line:
pet = next((pet for pet in pets if pet[“id”] == pet_id), None)

This article might help you understand this : https://www.geeksforgeeks.org/python-next-method/