I wrote a function such that if the passed val only has whitespaces in it for example '    ', they all get removed and we return np.Nan or a nullvalue.
def check_for_empty_spaces(val):
    val = val.rstrip()
    if len(val)<1:
        return np.NaN
    else:
        return val
        
print(len(check_for_empty_strings('WHAJS  ')))
print(check_for_empty_strings('WHAJS'))
print(check_for_empty_strings('  '))
print(check_for_empty_strings(''))    
The function returns as desired. The output is:
5
WHAJS
nan
nan
but now when I use this function, I want to check that the string is
- not just whitespaces
- not NULL
However, when I check this:
check = check_for_empty_strings('')
if (check):
    print('tru')
    print(check)
else:
    print('dsj')
I get this output
tru
nan
Why is the first one tru? If check == NaN then shouldn't if (check) be False? How else can I check that my value is not just whitespaces or NULL.
 
     
    