I have list of objects with attribute id and I want to find index of object with specific id. I wrote something like this:
index = -1
for i in range(len(my_list)):
if my_list[i].id == 'specific_id'
index = i
break
but it doesn't look very well. Are there any better options?