Advertisements
so I have the list:
['string_one', nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 'string_two', nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, 'string_three', nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, 'string_four', nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, "string_five", nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]
this list is in the def with parametr that equals to one of the strings from the list. I need to find index of the next string
upd:
I am using pandas and nan came from the excel table. I got the right answer, please stop downvote me 😉
>Solution :
There are many ways to do it, here is one of them:
my_list = ['x', None, None, 'y', None]
for index, elem in enumerate(my_list):
if elem is not None:
print(index)