python get first occurrence in list
next(obj for obj in objs if obj.val==5)
4.5
16
#iterate through list
for item in yourlist:
#if item is equal to a value
if item == 'value':
#store the item in a variable
yourvar = item
#break out of loop
break
Thank you!
16
0
Are there any code examples left?
New code examples in category Python