Created
July 19, 2020 09:01
-
-
Save raeq/c02f8fc70ed5e88e6c24aa52420020a2 to your computer and use it in GitHub Desktop.
Is Python String Empty or Blank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_null_or_blank(input_string: str = "") -> bool: | |
if input_string: | |
if input_string.strip(): | |
return False | |
return True | |
assert is_null_or_blank(None) == True | |
assert is_null_or_blank("") == True | |
assert is_null_or_blank(" ") == True | |
assert is_null_or_blank(" d ") == False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment