Sep-03-2022, 10:53 AM
Hi
I have following code which searches for index position of matching string without having to match everything:
I'm looking for a better way to accomplish this as my code is filled with many occurrences of this type of for loop appending to an empty list.
I thought about:
But it returns a list of boolean values instead of the index position of the match. I'm sure its simple but I'm not so competent in Python to know it.
Thanks
Matt
I have following code which searches for index position of matching string without having to match everything:
1 2 3 4 |
sheet_num = [] for x in range ( len (list_of_sheets)): if sheet_match in list_of_sheets[x]: sheet_num.append(x) |
I thought about:
1 |
list ( map ( lambda x: sheet_match in x, list_of_sheets)) |
Thanks
Matt