Can anyone help me understand the following piece of python code:
for i, char in filter(lambda x: x[1] in str1, enumerate(str2)):
# do something here ...
str1 and str2 are strings, I sort of understand that the "lambda x: x[1] in str1" is filtering condition, but why x[1] ?
How can I convert this for loop into a lower level (but easier to understand) python code ?
Thanks
enumeratereturns an iterable object contain the indices and items, so thexwould be a tuple contain each element with its index andx[1]is the item (character) itself.