Skip to content Skip to sidebar Skip to footer

How To Exclude Nonetype Class While Reading String In Python

I have a list that is pulled into python from Google Sheets. Some of the cells are empty and return a value of None. I checked the class type for these 'None' values and it says cl

Solution 1:

for i, valin enumerate(some_list):
    ifvalis not None:
        print (i,val)

If you wish to skip None and blank values:

for i, valin enumerate(some_list):
    ifvalis not None and val != "":
        print (i,val)

Solution 2:

In case, when gapes in i are not needed:

for i, val in enumerate([x for x in some_list if x]):
    ...

Post a Comment for "How To Exclude Nonetype Class While Reading String In Python"