Lets say I have following data:
l = ['abc', 'def', 'ghi']
sub = 'bc'
'bc' will allways be a substring for only one element in the list!
and a function that works like this:
def f(l, sub):
return [x for x in l if sub in x][0]
So the function will return 'abc' because it has 'bc' in it
My Question is: What is the other way to write that function so it doesn't use list index? ([0]) Is there a way to do this any 'prettier'?